CSS border-bottom-width Property
The border-bottom-width property sets the thickness of an element's physical bottom border.
It accepts nonnegative length values or the keywords thin, medium, and thick. A visible border style must also be specified for the border to appear. The property controls only the bottom border's width, leaving its style and color unchanged.
border-bottom-width Syntax
selector {
border-bottom-width: 4px;
}
The property accepts a nonnegative length or one of three predefined width keywords.
.thin-border {
border-bottom-width: thin;
}
.medium-border {
border-bottom-width: medium;
}
.thick-border {
border-bottom-width: thick;
}
.pixel-border {
border-bottom-width: 5px;
}
.relative-border {
border-bottom-width: 0.25rem;
}
.zero-border {
border-bottom-width: 0;
}
CSS-wide keywords are also supported:
.inherited {
border-bottom-width: inherit;
}
.reset {
border-bottom-width: initial;
}
.unset {
border-bottom-width: unset;
}
.reverted {
border-bottom-width: revert;
}
.layer-reverted {
border-bottom-width: revert-layer;
}
Only one width value is permitted. CSS-wide keywords must be used alone.
Property Values
| Value | Description |
|---|---|
thin |
Sets a thin border using a browser-defined width. |
medium |
Sets a medium border using a browser-defined width. This is the initial value. |
thick |
Sets a thick border using a browser-defined width. |
<length> |
Sets a nonnegative border width using a CSS length such as 2px, 0.2rem, or 0.25em. |
0 |
Sets the border width to zero, preventing it from occupying space. |
CSS-Wide Keywords
| Keyword | Behavior |
|---|---|
inherit |
Uses the parent's computed bottom border width. |
initial |
Resets the specified width to medium. |
unset |
Resets the specified width to medium because the property is not inherited. |
revert |
Reverts the property according to cascade origin rules. |
revert-layer |
Reverts the property according to cascade layer rules. |
The initial value is medium. The property is not inherited and supports animation as a length.
Percentage values and negative lengths are not permitted.
How It Works
The border-bottom-width property determines how much space the bottom border occupies when a visible border style is applied.
Setting a Bottom Border Width
.panel {
border-bottom-style: solid;
border-bottom-width: 5px;
border-bottom-color: #1769aa;
}
The element receives a solid blue bottom border with a thickness of 5 pixels.
Changing an Existing Width
.panel {
border-bottom: 2px solid #1769aa;
border-bottom-width: 8px;
}
The later declaration changes the border thickness to 8 pixels without changing its specified style or color.
Using the Default Width
.panel {
border-bottom-style: solid;
border-bottom-color: #1769aa;
}
The bottom border uses the initial medium width because no explicit width is provided.
Width Without a Border Style
.panel {
border-bottom-width: 8px;
}
If no other declaration sets a visible style, the bottom border remains invisible because border-bottom-style initially equals none.
Setting the Width to Zero
.panel {
border-bottom: 5px solid #1769aa;
border-bottom-width: 0;
}
The bottom border retains its specified style and color, but its zero width prevents it from appearing.
Keyword Widths
The thin, medium, and thick keywords provide predefined border thicknesses.
thin
.thin-example {
border-bottom: thin solid #1769aa;
}
The thin keyword produces a narrow bottom border.
medium
.medium-example {
border-bottom: medium solid #1769aa;
}
The medium keyword produces a border thicker than thin and is the initial width value.
thick
.thick-example {
border-bottom: thick solid #1769aa;
}
The thick keyword produces a border thicker than medium.
Keyword Comparison
| Keyword | Relative Thickness | Exact Pixel Width |
|---|---|---|
thin |
Smallest | Browser-defined |
medium |
Intermediate | Browser-defined |
thick |
Largest | Browser-defined |
The CSS specification does not require exact pixel measurements for these keywords. Browsers commonly use approximately 1, 3, and 5 pixels, but these values should not be treated as guaranteed.
Use an explicit length when precise border thickness is important.
Length Values
The property supports nonnegative CSS lengths, including absolute units, font-relative units, viewport-relative units, and compatible CSS math functions.
Pixel Width
.pixel-border {
border-bottom: 4px solid #1769aa;
}
Pixel values are useful when a consistent border thickness is required.
rem Width
.rem-border {
border-bottom-style: solid;
border-bottom-width: 0.25rem;
border-bottom-color: #1769aa;
}
The width is calculated relative to the root element's font size. With a root font size of 16 pixels, 0.25rem equals 4 pixels.
em Width
.em-border {
font-size: 20px;
border-bottom-style: solid;
border-bottom-width: 0.2em;
border-bottom-color: #1769aa;
}
With a font size of 20 pixels, 0.2em equals 4 pixels.
Viewport-Relative Width
.viewport-border {
border-bottom-style: solid;
border-bottom-width: 0.3vw;
border-bottom-color: #1769aa;
}
The specified width changes with the viewport width. This can create very thin or unusually thick borders at different viewport sizes.
Using calc()
.calculated-border {
border-bottom-style: solid;
border-bottom-width: calc(2px + 0.1rem);
border-bottom-color: #1769aa;
}
The calc() function combines compatible length values.
Using clamp()
.responsive-border {
border-bottom-style: solid;
border-bottom-width: clamp(2px, 0.4vw, 6px);
border-bottom-color: #1769aa;
}
The specified width responds to the viewport while remaining between 2 and 6 pixels.
Invalid Percentage
.invalid-percentage {
border-bottom-width: 10%;
}
Percentages are not valid values for border-bottom-width. The declaration is ignored.
Invalid Negative Width
.invalid-negative {
border-bottom-width: -4px;
}
Negative border widths are invalid and are ignored by the browser.
Border Style and Color
The bottom border's final appearance depends on its width, style, and color.
Separate Longhand Properties
.panel {
border-bottom-width: 5px;
border-bottom-style: solid;
border-bottom-color: #1769aa;
}
The three properties create a 5-pixel solid blue bottom border.
Equivalent Shorthand
.panel {
border-bottom: 5px solid #1769aa;
}
The border-bottom shorthand sets all three components in one declaration.
Different Border Styles
.solid-border {
border-bottom: 5px solid #1769aa;
}
.dashed-border {
border-bottom: 5px dashed #1769aa;
}
.dotted-border {
border-bottom: 5px dotted #1769aa;
}
.double-border {
border-bottom: 5px double #1769aa;
}
Each border uses the same specified width, but the line style changes its visual appearance.
Using currentColor
.panel {
color: #1769aa;
border-bottom-style: solid;
border-bottom-width: 4px;
}
When no border color is specified, the initial currentColor value uses the element's computed text color.
Transparent Border
.panel {
border-bottom: 5px solid transparent;
}
The border remains transparent but still occupies 5 pixels of space.
This distinction is useful when maintaining consistent dimensions between normal, hover, and active states.
Zero Width and Hidden Borders
A bottom border can become invisible because its width is zero, its style suppresses painting, or its color is transparent. These approaches do not always produce the same layout behavior.
Zero Width
.zero-width {
border-bottom: 0 solid #1769aa;
}
The border has a visible style but occupies no space because its width is zero.
Style Set to none
.no-border {
border-bottom-width: 8px;
border-bottom-style: none;
border-bottom-color: #1769aa;
}
The specified width is 8 pixels, but the used width is zero because the style is none.
Style Set to hidden
.hidden-border {
border-bottom-width: 8px;
border-bottom-style: hidden;
border-bottom-color: #1769aa;
}
The used width is also zero. The hidden style has additional significance when resolving collapsed table borders.
Transparent Border
.transparent-border {
border-bottom: 8px solid transparent;
}
The border is invisible, but its 8-pixel width still contributes to the element's dimensions.
Comparison
| Declaration | Visible Border | Used Width |
|---|---|---|
border-bottom: 0 solid blue; |
No | 0 |
border-bottom: 8px none blue; |
No | 0 |
border-bottom: 8px hidden blue; |
No | 0 |
border-bottom: 8px solid transparent; |
No | 8px |
Use a transparent border when an invisible border must continue occupying space. Use a zero width or a suppressing border style when no border thickness is needed.
Shorthand Interactions
The border-bottom-width property can be set or reset by several border shorthand properties.
Overriding border-bottom
.panel {
border-bottom: 2px solid #1769aa;
border-bottom-width: 8px;
}
The later longhand changes only the bottom border width to 8 pixels.
Shorthand After Longhand
.panel {
border-bottom-width: 8px;
border-bottom: 2px solid #1769aa;
}
The later shorthand resets the bottom border width to 2 pixels.
Omitted Width in Shorthand
.panel {
border-bottom-width: 8px;
border-bottom: solid #1769aa;
}
The later shorthand resets the width to its initial value of medium.
Using border-width
.panel {
border-bottom-width: 8px;
border-width: 2px;
}
The later border-width shorthand sets all four border widths to 2 pixels.
Four-Side border-width Values
.panel {
border-style: solid;
border-width: 2px 4px 6px 8px;
}
The values apply clockwise: top is 2 pixels, right is 4 pixels, bottom is 6 pixels, and left is 8 pixels.
Using the border Shorthand
.panel {
border-bottom-width: 8px;
border: 2px solid #777;
}
The later border shorthand sets all four border widths to 2 pixels.
These examples assume declarations with equal cascade priority. Specificity, importance, origins, and cascade layers can change which declaration takes precedence.
Logical vs. Physical Border Widths
The border-bottom-width property always targets the physical bottom edge. Logical border width properties follow the element's writing mode and text direction.
Physical Bottom Border
.physical-border {
writing-mode: vertical-rl;
border-style: solid;
border-bottom-width: 6px;
}
The physical bottom border receives a 6-pixel width, regardless of the writing mode.
Logical Border Mapping
| Writing Mode | Direction | Logical Property for Bottom Border |
|---|---|---|
horizontal-tb |
ltr or rtl |
border-block-end-width |
vertical-rl |
ltr |
border-inline-end-width |
vertical-rl |
rtl |
border-inline-start-width |
vertical-lr |
ltr |
border-inline-end-width |
vertical-lr |
rtl |
border-inline-start-width |
Horizontal Writing Mode
.logical-border {
writing-mode: horizontal-tb;
border-style: solid;
border-block-end-width: 6px;
}
In horizontal writing, the block-end edge maps to the physical bottom edge.
Vertical Writing Mode
.logical-border {
writing-mode: vertical-rl;
direction: ltr;
border-style: solid;
border-inline-end-width: 6px;
}
With vertical-rl and direction: ltr, the inline-end edge maps to the physical bottom border.
Use border-bottom-width when the physical bottom edge must remain fixed. Use logical border width properties when the edge should adapt to the writing mode.
Box Model and Layout
A visible bottom border contributes to an element's box dimensions. Its effect depends on the box-sizing property.
Using content-box
.content-box-example {
box-sizing: content-box;
width: 240px;
height: 100px;
border-bottom: 10px solid #1769aa;
}
With no padding or other borders, the outer height becomes 110 pixels because the 10-pixel bottom border is added to the declared content height.
Using border-box
.border-box-example {
box-sizing: border-box;
width: 240px;
height: 100px;
border-bottom: 10px solid #1769aa;
}
The declared height includes the bottom border. With no padding or other borders, the content area has 90 pixels of available height.
Changing Border Thickness
.panel {
box-sizing: content-box;
border-bottom: 2px solid #1769aa;
}
.panel:hover {
border-bottom-width: 8px;
}
Increasing the border width can change the element's outer dimensions and affect surrounding layout.
Avoiding Layout Changes
.panel {
border-bottom: 8px solid transparent;
}
.panel:hover {
border-bottom-color: #1769aa;
}
The border reserves the same space in both states. Changing only its color avoids a border-width-related layout shift.
Using an Outline Instead
.panel:focus-visible {
outline: 3px solid #1769aa;
outline-offset: 3px;
}
Unlike borders, outlines do not occupy space in the CSS box model. They are useful for focus indicators that should not change layout dimensions.
Transitions and Animation
Bottom border widths can be animated between compatible length values.
Hover Transition
.animated-border {
border-bottom: 2px solid #1769aa;
transition: border-bottom-width 250ms ease;
}
.animated-border:hover {
border-bottom-width: 8px;
}
@media (prefers-reduced-motion: reduce) {
.animated-border {
transition: none;
}
}
The bottom border gradually changes from 2 to 8 pixels when the pointer moves over the element.
Focus Transition
.focus-border {
border-bottom: 2px solid #777;
transition: border-bottom-width 200ms ease;
}
.focus-border:focus-visible {
border-bottom-width: 5px;
outline: 2px solid #1769aa;
outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
.focus-border {
transition: none;
}
}
The border becomes thicker when the element receives visible keyboard focus.
Keyframe Animation
.animated-divider {
border-bottom: 2px solid #1769aa;
animation: divider-width 2s ease-in-out infinite alternate;
}
@keyframes divider-width {
from {
border-bottom-width: 2px;
}
to {
border-bottom-width: 8px;
}
}
@media (prefers-reduced-motion: reduce) {
.animated-divider {
animation: none;
}
}
The animation repeatedly changes the bottom border thickness between 2 and 8 pixels.
Animating border width can cause layout recalculation. For purely decorative effects, a transform-based pseudo-element may provide a smoother alternative.
Practical Uses
Bottom border widths are useful for headings, navigation indicators, content separators, and form controls.
Heading Underline
.section-heading {
border-bottom: 3px solid #1769aa;
padding-bottom: 10px;
}
A 3-pixel bottom border creates a clear divider beneath a section heading.
Active Navigation Indicator
.nav-link {
border-bottom: 4px solid transparent;
}
.nav-link[aria-current="page"] {
border-bottom-color: #1769aa;
}
The transparent border reserves space for the active indicator, maintaining consistent dimensions.
Subtle Content Divider
.content-item {
border-bottom: 1px solid #d0d7de;
padding-bottom: 16px;
}
A 1-pixel border separates repeated content items without creating a heavy visual divider.
Emphasized Divider
.featured-section {
border-bottom: 6px solid #1769aa;
padding-bottom: 20px;
}
A thicker border gives the section greater visual emphasis.
Input Underline
.underline-input {
border: none;
border-bottom: 2px solid #777;
}
.underline-input:focus-visible {
border-bottom-width: 4px;
border-bottom-color: #1769aa;
outline: 2px solid #1769aa;
outline-offset: 2px;
}
The bottom border becomes thicker when the input receives keyboard focus. The outline provides an additional visible focus indicator.
Responsive Border Thickness
.responsive-divider {
border-bottom-style: solid;
border-bottom-width: clamp(2px, 0.4vw, 6px);
border-bottom-color: #1769aa;
}
The border thickness responds to the viewport while remaining between the specified minimum and maximum values.
border-bottom-width Example
The following example compares the three predefined width keywords with explicit pixel widths and a zero-width border.
<div class="bottom-width-demo">
<div class="demo-box thin">thin</div>
<div class="demo-box medium">medium</div>
<div class="demo-box thick">thick</div>
<div class="demo-box two-pixels">2px</div>
<div class="demo-box five-pixels">5px</div>
<div class="demo-box ten-pixels">10px</div>
<div class="demo-box zero">0</div>
</div>
.bottom-width-demo {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
gap: 16px;
}
.bottom-width-demo .demo-box {
box-sizing: border-box;
display: flex;
align-items: center;
justify-content: center;
min-height: 90px;
padding: 16px;
border-bottom-style: solid;
border-bottom-color: #1769aa;
background-color: #e8f2fb;
color: #173b5e;
font-weight: bold;
text-align: center;
}
.bottom-width-demo .thin {
border-bottom-width: thin;
}
.bottom-width-demo .medium {
border-bottom-width: medium;
}
.bottom-width-demo .thick {
border-bottom-width: thick;
}
.bottom-width-demo .two-pixels {
border-bottom-width: 2px;
}
.bottom-width-demo .five-pixels {
border-bottom-width: 5px;
}
.bottom-width-demo .ten-pixels {
border-bottom-width: 10px;
}
.bottom-width-demo .zero {
border-bottom-width: 0;
}
The thin, medium, and thick examples use browser-defined widths.
The 2px, 5px, and 10px examples use explicit lengths for more predictable thicknesses.
The final example uses a zero-width bottom border. Although its style is solid, the border is not visible.
Important Considerations
Keep the following points in mind when using border-bottom-width:
- Physical edge: Always controls the physical bottom border, regardless of writing mode.
- Initial value: The initial specified width is
medium. - Inheritance: The property is not inherited.
- Keyword values:
thin,medium, andthickuse browser-defined thicknesses. - Length values: Nonnegative CSS lengths are supported.
- Percentage values: Percentages are not permitted.
- Negative values: Negative widths are invalid.
- Zero width: A width of zero prevents the border from occupying space.
- Visible style: A visible border style is required for a nonzero used width.
- none and hidden: These styles force the used border width to zero.
- Default color: The initial border color is
currentColor. - Transparent borders: A transparent border with a visible style and nonzero width still occupies space.
- Box model: Border thickness contributes to the element's dimensions according to
box-sizing. - Shorthand interactions: Later border shorthand declarations may reset the specified width.
- Logical alternatives: Use logical border width properties when the edge should follow the writing mode.
- Animation: Compatible width values can be interpolated during transitions and animations.
- Layout changes: Changing border thickness may affect surrounding layout.
- Rendering: Very thin borders and fractional widths may be rounded or rendered differently depending on device resolution.
Use border-bottom-width when the thickness of the physical bottom border needs to change without resetting its specified style or color.
Browser Support
The border-bottom-width 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. The predefined width keywords may resolve to slightly different measurements between browsers.
Standard Declaration
.panel {
border-bottom-style: solid;
border-bottom-width: 4px;
border-bottom-color: #1769aa;
}
Keyword Declaration
.panel {
border-bottom-style: solid;
border-bottom-width: thick;
}
Both explicit length values and predefined width keywords are supported in modern browsers.
Visit Can I Use? and search for border-bottom-width to review browser compatibility.
Specifications
The border-bottom-width property is defined in the CSS Backgrounds and Borders Module Level 3 specification.
CSS Backgrounds and Borders Module Level 3
Logical border width properties are defined in the CSS Logical Properties and Values Module Level 1 specification.
