Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Borders, Outlines and Shadows

The border-bottom property

Reference for the CSS border-bottom shorthand: set the width, style and color of only the bottom border, for underlines, tabs and dividers, with examples.

The border-bottom property is a shorthand that sets the width, style and color of an element's bottom border only. Its longhands are border-bottom-width, border-bottom-style and border-bottom-color.

It is the classic way to draw a rule under a heading, an underline-like active tab, or a field that has only a line at its base.

CSS
h2 {
  border-bottom: 2px solid #e2e8f0;
  padding-bottom: 0.25em;
}

Try it

Headings, tabs and inputs

The active tab pulls down by 1px with a negative margin so its blue line sits on top of the gray rule. In the input, outline: none is only safe because the bottom color change replaces the focus indicator; keep a visible cue whenever you do this.

Syntax

CSS
border-bottom: <line-width> || <line-style> || <color>
  • Initial value: medium none currentcolor
  • Applies to: all elements
  • Inherited: no
  • Animatable: yes (width and color; style is discrete)
  • Computed value: see the longhands

Values

Value Description
<line-width> A length or thin, medium, thick. See border-width.
<line-style> solid, dashed, dotted, double, groove, ridge, inset, outset, none, hidden. See border-style.
<color> Any color value; omitted means currentcolor.

Usage notes

  • Pseudo-underlines. A bottom border is a rough substitute for an underline. For real text underlines prefer text-decoration, which follows the text shape and wraps correctly across lines. A border sits at the bottom of the box, not at the text baseline, so it can look different from an underline.
  • Reserve space ahead of time. Use border-bottom: 3px solid transparent on all tabs and change only the color for the active one. Nothing shifts.
  • Removing outlines. If you take away the default focus outline from an input, give users another visible way to see focus.
  • Headings. Pair a bottom border with padding-bottom so the line is not glued to the text.
  • Logical alternative. border-block-end follows the writing mode and is the right choice for vertical text.
  • Override order. Put border first and border-bottom after it.
  • Tables. Bottom borders on rows work well with border-collapse: collapse.

Browser support

Supported in every browser.