CSS border-bottom Property
The border-bottom property is a shorthand that sets the width, style, and color of an element's bottom border.
It combines three individual border properties into one declaration. The bottom border remains on the physical bottom edge regardless of the element's writing mode or text direction, making it useful for dividers, navigation indicators, form controls, and decorative accents.
border-bottom Syntax
selector {
border-bottom: 3px solid #1769aa;
}
The shorthand accepts a border width, style, and color in any order. Each component is optional, but at least one must be provided.
.solid-border {
border-bottom: 3px solid #1769aa;
}
.dashed-border {
border-bottom: 2px dashed #d35400;
}
.dotted-border {
border-bottom: dotted;
}
.color-and-style {
border-bottom: solid red;
}
.width-and-style {
border-bottom: 4px double;
}
.no-border {
border-bottom: none;
}
CSS-wide keywords are also supported:
.inherited {
border-bottom: inherit;
}
.reset {
border-bottom: initial;
}
.unset {
border-bottom: unset;
}
.reverted {
border-bottom: revert;
}
.layer-reverted {
border-bottom: revert-layer;
}
CSS-wide keywords must be used alone. They cannot be combined with individual border width, style, or color values.
Property Values
| Component | Accepted Values | Description |
|---|---|---|
| Width | thin, medium, thick, <length> |
Sets the thickness of the bottom border. |
| Style | none, hidden, solid, dashed, dotted, double, groove, ridge, inset, outset |
Determines how the bottom border is drawn. |
| Color | <color> |
Sets the bottom border color using any supported CSS color value. |
Initial Values
| Longhand Property | Initial Value |
|---|---|
border-bottom-width |
medium |
border-bottom-style |
none |
border-bottom-color |
currentColor |
The shorthand is not inherited. Omitted components are reset to their initial values, rather than retaining previously specified values.
How It Works
The border-bottom property defines a border along the physical bottom edge of an element.
Complete Declaration
.panel {
border-bottom: 4px solid #1769aa;
}
This creates a 4-pixel solid blue border along the bottom of the element.
Style Only
.panel {
border-bottom: solid;
}
The border uses the initial width of medium and the initial color of currentColor.
Width and Style
.panel {
color: #1769aa;
border-bottom: 3px dashed;
}
The border uses the element's current text color because no border color is specified.
Color Only
.panel {
border-bottom: red;
}
The shorthand sets the border color to red, but the border remains invisible because the omitted style resets to none.
Removing the Bottom Border
.panel {
border-bottom: none;
}
The bottom border is removed. Its style becomes none, its specified width resets to medium, and its color resets to currentColor. The used width is zero.
Border Widths
The width component determines the thickness of the bottom border.
Predefined Width Keywords
.thin-border {
border-bottom: thin solid #1769aa;
}
.medium-border {
border-bottom: medium solid #1769aa;
}
.thick-border {
border-bottom: thick solid #1769aa;
}
The browser determines the exact thickness of thin, medium, and thick. Use explicit lengths for precise measurements.
Pixel Widths
.pixel-border {
border-bottom: 5px solid #1769aa;
}
Relative Widths
.relative-border {
border-bottom: 0.25rem solid #1769aa;
}
Relative lengths such as em and rem can scale with font sizes.
Calculated Widths
.calculated-border {
border-bottom: calc(2px + 0.1rem) solid #1769aa;
}
Zero Width
.zero-border {
border-bottom: 0 solid #1769aa;
}
The border has zero thickness and is not visible.
Border widths must be nonnegative lengths or predefined width keywords. Negative lengths and percentages are invalid.
Border Styles
The style component controls the appearance of the bottom border. A visible border generally requires a style other than none or hidden.
| Style | Appearance |
|---|---|
none |
No visible border. |
hidden |
No visible border, with special behavior in collapsed table borders. |
solid |
A continuous line. |
dashed |
A series of short line segments. |
dotted |
A series of dots. |
double |
Two parallel lines separated by a gap. |
groove |
A recessed appearance. |
ridge |
A raised appearance. |
inset |
A sunken appearance. |
outset |
A raised appearance opposite to inset. |
Comparing Common Styles
.solid-example {
border-bottom: 4px solid #1769aa;
}
.dashed-example {
border-bottom: 4px dashed #1769aa;
}
.dotted-example {
border-bottom: 4px dotted #1769aa;
}
.double-example {
border-bottom: 6px double #1769aa;
}
The double style uses the specified width for both lines and the gap combined. Dashed and dotted patterns may vary slightly between browsers.
none vs. hidden
.no-border {
border-bottom: none;
}
.hidden-border {
border-bottom: hidden;
}
Both styles suppress the border and produce a used width of zero. In collapsed table border conflict resolution, hidden suppresses competing borders, while none has the lowest precedence.
Border Colors
The color component accepts CSS color values, including named colors, hexadecimal notation, color functions, and custom properties.
Named Color
.named-color {
border-bottom: 3px solid red;
}
Hexadecimal Color
.hex-color {
border-bottom: 3px solid #1769aa;
}
RGB Color
.rgb-color {
border-bottom: 3px solid rgb(23 105 170);
}
HSL Color
.hsl-color {
border-bottom: 3px solid hsl(207 76% 38%);
}
currentColor
.current-color {
color: #1769aa;
border-bottom: 3px solid currentColor;
}
The currentColor keyword uses the element's computed text color. It is also the initial value of border-bottom-color.
Transparent Border
.transparent-border {
border-bottom: 4px solid transparent;
}
A transparent border remains part of the box model even though it is not visibly painted.
Custom Property
.custom-color {
--accent-color: #1769aa;
border-bottom: 3px solid var(--accent-color);
}
Custom properties make it easier to reuse consistent border colors throughout a design.
Shorthand Behavior
The border-bottom shorthand sets all three constituent properties, even when only one or two components are explicitly provided.
Omitted Components Reset
.panel {
border-bottom: 5px dashed red;
border-bottom: solid;
}
The second declaration resets the width to medium and the color to currentColor. The final border style is solid.
Declaration Order
.panel {
border-bottom: 2px solid #1769aa;
border-bottom-width: 6px;
}
The later longhand changes the width to 6 pixels while preserving the solid style and blue color.
Longhand Before Shorthand
.panel {
border-bottom-width: 6px;
border-bottom: 2px solid #1769aa;
}
The later shorthand resets the width to 2 pixels.
Using the border Shorthand
.panel {
border: 1px solid #d0d7de;
border-bottom: 4px solid #1769aa;
}
All four sides receive a 1-pixel gray border, but the bottom border is overridden with a 4-pixel blue border.
Removing a Previously Defined Border
.panel {
border: 2px solid #1769aa;
border-bottom: none;
}
The top, right, and left borders remain visible, while the bottom border is removed.
These examples assume equal cascade origin, importance, specificity, and layer priority. Higher-priority declarations can override later declarations.
Constituent Longhand Properties
The border-bottom shorthand combines three individual properties.
| Property | Purpose |
|---|---|
border-bottom-width |
Controls the thickness of the bottom border. |
border-bottom-style |
Controls the line style of the bottom border. |
border-bottom-color |
Controls the color of the bottom border. |
Shorthand Declaration
.panel {
border-bottom: 4px solid #1769aa;
}
Equivalent Longhand Declarations
.panel {
border-bottom-width: 4px;
border-bottom-style: solid;
border-bottom-color: #1769aa;
}
Both examples produce the same bottom border.
Changing Only the Color
.panel {
border-bottom: 4px solid #1769aa;
}
.panel:hover {
border-bottom-color: #d35400;
}
The hover rule changes the border color without resetting its width or style.
Changing Only the Style
.panel {
border-bottom: 4px solid #1769aa;
}
.panel.emphasized {
border-bottom-style: double;
}
The bottom border becomes double while retaining its specified width and color.
Logical vs. Physical Borders
The border-bottom property always targets the physical bottom edge. Logical border properties follow the writing mode.
| Writing Mode | border-bottom |
border-block-end |
|---|---|---|
horizontal-tb |
Bottom | Bottom |
vertical-rl |
Bottom | Left |
vertical-lr |
Bottom | Right |
sideways-rl |
Bottom | Left |
sideways-lr |
Bottom | Right |
Physical Bottom Border
.physical-border {
writing-mode: vertical-rl;
border-bottom: 4px solid #1769aa;
}
The border remains on the physical bottom edge.
Logical Block-End Border
.logical-border {
writing-mode: vertical-rl;
border-block-end: 4px solid #1769aa;
}
The border appears on the physical left edge because that is the block-end side in vertical-rl.
Logical Inline-End Border
.inline-border {
writing-mode: vertical-rl;
direction: ltr;
border-inline-end: 4px solid #1769aa;
}
In this example, the inline-end side maps to the physical bottom edge.
Use border-bottom when the border must remain on the bottom. Use logical border properties when the border should follow the text flow.
Borders and the Box Model
The used bottom border width contributes to the element's border-box dimensions. Its effect depends on the box-sizing property.
content-box
.content-box-panel {
box-sizing: content-box;
width: 300px;
height: 100px;
padding: 20px;
border-bottom: 5px solid #1769aa;
}
The content height is 100 pixels. The top and bottom padding add 40 pixels, and the bottom border adds 5 pixels. With no other vertical borders, the total border-box height is 145 pixels.
border-box
.border-box-panel {
box-sizing: border-box;
width: 300px;
height: 100px;
padding: 20px;
border-bottom: 5px solid #1769aa;
}
The declared 100-pixel height includes the content, padding, and bottom border.
Avoiding Layout Changes on Hover
.navigation-link {
border-bottom: 3px solid transparent;
}
.navigation-link:hover {
border-bottom-color: #1769aa;
}
The transparent border reserves space before hover. Changing only the color avoids changing the border thickness.
Animating Border Color
.animated-link {
border-bottom: 3px solid transparent;
transition: border-bottom-color 200ms ease;
}
.animated-link:hover {
border-bottom-color: #1769aa;
}
@media (prefers-reduced-motion: reduce) {
.animated-link {
transition: none;
}
}
Animating the border color provides a visual transition without changing the element's dimensions.
Practical Uses
Bottom borders are commonly used for visual separation, navigation indicators, and form controls.
Section Divider
.content-section {
border-bottom: 1px solid #d0d7de;
padding-bottom: 20px;
margin-bottom: 20px;
}
A thin bottom border separates adjacent content sections.
Heading Underline
.section-heading {
border-bottom: 3px solid #1769aa;
padding-bottom: 10px;
}
The border creates a visual accent beneath the heading.
Active Navigation Link
.nav-link {
border-bottom: 3px solid transparent;
}
.nav-link[aria-current="page"] {
border-bottom-color: #1769aa;
}
The active navigation link receives a visible bottom border. The aria-current attribute also communicates the current page to assistive technologies.
Minimal Form Field
.minimal-input {
border: 0;
border-bottom: 2px solid #777;
padding: 8px 4px;
}
.minimal-input:focus-visible {
border-bottom-color: #1769aa;
outline: 2px solid #1769aa;
outline-offset: 2px;
}
The input uses a bottom border for its visual design while retaining a visible keyboard focus indicator.
Dashed Divider
.summary-divider {
border-bottom: 2px dashed #1769aa;
padding-bottom: 16px;
}
A dashed border creates a lighter visual separator than a solid line of the same thickness.
border-bottom Example
The following example demonstrates solid, dashed, dotted, and double bottom borders, along with a border that uses the element's current text color.
<div class="border-bottom-demo">
<div class="demo-box solid">Solid Bottom Border</div>
<div class="demo-box dashed">Dashed Bottom Border</div>
<div class="demo-box dotted">Dotted Bottom Border</div>
<div class="demo-box double">Double Bottom Border</div>
<div class="demo-box current">currentColor Border</div>
</div>
.border-bottom-demo {
display: flex;
flex-wrap: wrap;
gap: 16px;
}
.border-bottom-demo .demo-box {
box-sizing: border-box;
width: 190px;
padding: 20px 12px;
background-color: #e8f2fb;
color: #173b5e;
font-weight: bold;
text-align: center;
}
.border-bottom-demo .solid {
border-bottom: 4px solid #1769aa;
}
.border-bottom-demo .dashed {
border-bottom: 4px dashed #1769aa;
}
.border-bottom-demo .dotted {
border-bottom: 4px dotted #1769aa;
}
.border-bottom-demo .double {
border-bottom: 6px double #1769aa;
}
.border-bottom-demo .current {
color: #a33c21;
border-bottom: 4px solid currentColor;
}
The first four boxes demonstrate different border styles and widths. The fifth box uses currentColor, causing the bottom border to match the element's text color.
Only the physical bottom edge is affected in each example.
Important Considerations
Keep the following points in mind when using border-bottom:
- Shorthand property: Sets the width, style, and color of the physical bottom border.
- Physical edge: Always targets the bottom, regardless of writing mode or text direction.
- Optional components: Width, style, and color can appear in any order.
- Initial width: The default border width is
medium. - Initial style: The default border style is
none. - Initial color: The default border color is
currentColor. - Omitted components: Unspecified components reset to their initial values.
- Inheritance: The constituent border properties are not inherited.
- Visible borders: A visible style and nonzero used width are generally required.
- none and hidden: Both produce a used border width of zero.
- Width values: Nonnegative lengths and the keywords
thin,medium, andthickare supported. - Color values: CSS colors, including
transparentandcurrentColor, are supported. - Longhand properties: Use
border-bottom-width,border-bottom-style, orborder-bottom-colorto change one component. - Shorthand resets: Later border shorthands can override previously defined values.
- Logical alternative: Use
border-block-endorborder-inline-endwhen the border should follow the appropriate logical edge. - Box model: The used border width contributes to the element's dimensions.
- Hover effects: Changing border color instead of width can avoid layout changes.
- Accessibility: Do not rely on a bottom border alone to communicate important states without appropriate text or semantic information.
Use border-bottom when the width, style, and color of the physical bottom border should be defined together.
Browser Support
The border-bottom property is widely supported across Chrome, Edge, Firefox, Safari, and other major browsers, including older browser versions.
The standard property does not require vendor prefixes. Support for newer CSS color functions or math functions used within the shorthand may vary independently.
Standard Declaration
.panel {
border-bottom: 4px solid #1769aa;
}
No fallback is generally required for the basic shorthand.
Visit Can I Use? and search for border-bottom to review browser compatibility and related features.
Specifications
The border-bottom property is defined in the CSS Backgrounds and Borders Module Level 3 specification.
CSS Backgrounds and Borders Module Level 3
Logical alternatives to physical borders are defined in the CSS Logical Properties and Values Module Level 1 specification.
