CSS border-block-width Property

The border-block-width property is a shorthand that sets the thickness of an element's logical block-start and block-end borders.

It accepts one or two width values, allowing both borders to have the same thickness or different thicknesses. The physical edges affected depend on the element's writing mode. This property changes border widths without changing their specified styles or colors.

border-block-width Syntax

selector {
  border-block-width: 4px;
}

The property accepts one or two nonnegative CSS lengths or predefined border-width keywords.

.same-width {
  border-block-width: 4px;
}
.different-widths {
  border-block-width: 6px 2px;
}
.keyword-width {
  border-block-width: thin thick;
}
.relative-width {
  border-block-width: 0.25rem;
}
.zero-width {
  border-block-width: 0;
}

CSS-wide keywords are also supported:

.inherited {
  border-block-width: inherit;
}
.reset {
  border-block-width: initial;
}
.unset {
  border-block-width: unset;
}
.reverted {
  border-block-width: revert;
}
.layer-reverted {
  border-block-width: revert-layer;
}

CSS-wide keywords must be used alone. They cannot be combined with individual width values in the same declaration.

Property Values

Value Description
thin A thin border using a browser-defined thickness.
medium A medium border using a browser-defined thickness. This is the initial width of both borders.
thick A thick border using a browser-defined thickness.
<length> A nonnegative CSS length such as 2px, 0.25rem, or 0.2em.
0 Sets the border thickness to zero.

CSS-Wide Keywords

Keyword Behavior
inherit Uses the parent's computed block-start and block-end border widths.
initial Resets both widths to medium.
unset Resets both widths to medium because they are not inherited.
revert Reverts both constituent properties according to cascade origin rules.
revert-layer Reverts both constituent properties according to cascade layer rules.

The shorthand is not inherited. Its constituent properties have an initial value of medium and animate as lengths.

Negative lengths and percentages are invalid. The property accepts a maximum of two width values.

How It Works

The border-block-width property controls the thickness of two logical borders without changing their specified styles or colors.

Setting Both Border Widths

.panel {
  border-block-style: solid;
  border-block-color: #1769aa;
  border-block-width: 4px;
}

Both block-start and block-end borders are solid blue lines, each 4 pixels thick.

Setting Different Widths

.panel {
  border-block-style: solid;
  border-block-color: #1769aa;
  border-block-width: 6px 2px;
}

The block-start border is 6 pixels thick, while the block-end border is 2 pixels thick.

Changing Existing Border Widths

.panel {
  border-block: 2px solid #1769aa;
  border-block-width: 8px 3px;
}

The later declaration changes the block-start width to 8 pixels and the block-end width to 3 pixels. Both borders remain solid and blue.

Width Without Style

.panel {
  border-block-width: 6px;
}

If no other border declarations apply, the borders remain invisible because their initial styles are none.

One or Two Values

The number of values determines how the widths are distributed between the logical block-start and block-end borders.

One Value

.panel {
  border-block-width: 5px;
}

Both logical block borders receive a width of 5 pixels.

Two Values

.panel {
  border-block-width: 8px 2px;
}

The first value sets the block-start width to 8 pixels, and the second sets the block-end width to 2 pixels.

Mixing Keywords and Lengths

.panel {
  border-block-width: thick 2px;
}

The block-start border uses the browser-defined thick width, while the block-end border uses 2 pixels.

Removing One Border's Thickness

.panel {
  border-block-style: solid;
  border-block-width: 5px 0;
}

The block-start border has a width of 5 pixels, while the block-end border has no thickness.

Invalid Number of Values

.invalid {
  border-block-width: 2px 4px 6px;
}

Three width values are invalid. Browsers ignore the entire declaration.

Writing Modes and Border Mapping

The border-block-width property follows the logical block axis rather than fixed physical edges.

Writing Mode Block-Start Block-End
horizontal-tb Top Bottom
vertical-rl Right Left
vertical-lr Left Right
sideways-rl Right Left
sideways-lr Left Right

Horizontal Writing Mode

.horizontal {
  writing-mode: horizontal-tb;
  border-block: solid #1769aa;
  border-block-width: 8px 2px;
}

The top border is 8 pixels thick, and the bottom border is 2 pixels thick.

Vertical Right-to-Left Writing Mode

.vertical-right {
  writing-mode: vertical-rl;
  border-block: solid #1769aa;
  border-block-width: 8px 2px;
}

The right border is 8 pixels thick, and the left border is 2 pixels thick.

Vertical Left-to-Right Writing Mode

.vertical-left {
  writing-mode: vertical-lr;
  border-block: solid #1769aa;
  border-block-width: 8px 2px;
}

The left border is 8 pixels thick, and the right border is 2 pixels thick.

Text Direction

.rtl-panel {
  direction: rtl;
  writing-mode: horizontal-tb;
  border-block: solid #1769aa;
  border-block-width: 8px 2px;
}

Changing direction alone does not change the physical positions of the block-start and block-end borders in horizontal writing mode.

Border Width Keywords

The predefined width keywords thin, medium, and thick provide browser-defined border thicknesses.

thin

.thin-example {
  border-block: solid #1769aa;
  border-block-width: thin;
}

Both block borders use a thin width.

medium

.medium-example {
  border-block: solid #1769aa;
  border-block-width: medium;
}

Both borders use the initial width of medium.

thick

.thick-example {
  border-block: solid #1769aa;
  border-block-width: thick;
}

Both borders use a thick width.

Different Keyword Widths

.mixed-example {
  border-block: solid #1769aa;
  border-block-width: thick thin;
}

The block-start border is thick, while the block-end border is thin.

The exact pixel values of these keywords are browser-defined. Use explicit lengths when precise measurements are required.

Length Values and CSS Functions

The property accepts nonnegative CSS lengths, including absolute and relative units.

Pixel Values

.pixel-border {
  border-block: solid #1769aa;
  border-block-width: 6px 2px;
}

Pixel values are useful when precise border thicknesses are required.

em Values

.em-border {
  font-size: 20px;
  border-block: solid #1769aa;
  border-block-width: 0.3em 0.1em;
}

With a 20-pixel font size, the specified widths are 6 pixels and 2 pixels.

rem Values

.rem-border {
  border-block: solid #1769aa;
  border-block-width: 0.375rem 0.125rem;
}

With a 16-pixel root font size, the specified widths are 6 pixels and 2 pixels.

Using calc()

.calculated-border {
  border-block: solid #1769aa;
  border-block-width: calc(2px + 0.2rem) 2px;
}

The calc() function combines compatible length values to calculate the block-start width.

Using clamp()

.responsive-border {
  border-block: solid #1769aa;
  border-block-width: clamp(2px, 0.4vw, 8px) 2px;
}

The block-start width is limited to a minimum of 2 pixels and a maximum of 8 pixels.

Invalid Values

.invalid-negative {
  border-block-width: -2px;
}
.invalid-percentage {
  border-block-width: 10%;
}

Negative lengths and percentages are invalid. Browsers ignore these declarations.

Border Visibility

Border widths contribute to visible borders only when the corresponding styles permit them to be drawn.

Width Without Style

.invisible {
  border-block-width: 5px;
  border-block-color: red;
}

The borders remain invisible if their styles are none.

Adding a Visible Style

.visible {
  border-block-width: 5px;
  border-block-style: solid;
  border-block-color: red;
}

Both borders become visible because their styles are solid.

Zero Width

.zero-width {
  border-block: solid red;
  border-block-width: 0;
}

Both borders have zero thickness and are not visible.

Transparent Borders

.transparent {
  border-block: solid transparent;
  border-block-width: 5px;
}

Both borders occupy space but are not visibly painted.

none and hidden

.none-style {
  border-block-width: 5px;
  border-block-style: none;
}
.hidden-style {
  border-block-width: 5px;
  border-block-style: hidden;
}

Both styles produce used border widths of zero. The hidden style also has special precedence in collapsed table border conflicts.

Constituent Longhand Properties

The border-block-width shorthand sets two longhand properties.

Longhand Property Purpose
border-block-start-width Controls the thickness of the logical block-start border.
border-block-end-width Controls the thickness of the logical block-end border.

Shorthand Declaration

.panel {
  border-block-width: 8px 2px;
}

Equivalent Longhand Declarations

.panel {
  border-block-start-width: 8px;
  border-block-end-width: 2px;
}

Both examples assign 8 pixels to block-start and 2 pixels to block-end.

Overriding One Side

.panel {
  border-block-width: 4px;
  border-block-start-width: 8px;
}

The block-start border becomes 8 pixels thick, while the block-end border remains 4 pixels thick.

Resetting Both Widths

.panel {
  border-block-width: initial;
}

Both constituent widths reset to medium.

Shorthand Interactions

Other border shorthands can set or reset the widths controlled by border-block-width.

Overriding border-block

.panel {
  border-block: 3px solid #1769aa;
  border-block-width: 8px 2px;
}

The later declaration changes the widths to 8 pixels and 2 pixels while preserving the solid styles and blue colors.

Reset by border-block

.panel {
  border-block-width: 8px 2px;
  border-block: 3px solid #1769aa;
}

The later border-block shorthand replaces both widths with 3 pixels.

Using border-block-start

.panel {
  border-block: 3px solid #1769aa;
  border-block-width: 8px 2px;
  border-block-start: 5px dashed #d35400;
}

The block-start border becomes 5 pixels thick, dashed, and orange. The block-end border remains 2 pixels thick, solid, and blue.

Using the border Shorthand

.panel {
  border-block-width: 8px 2px;
  border: 3px solid gray;
}

The later border shorthand sets all four physical border widths to 3 pixels, overriding the earlier logical widths.

Cascade Priority

These examples assume equal origin, importance, specificity, and cascade layer priority. Higher-priority declarations can override later declarations.

For predictable results, establish general border rules first and apply specific logical width overrides afterward.

Borders and the Box Model

The used block-start and block-end border widths contribute to the element's block-axis dimensions.

content-box

.content-box-panel {
  box-sizing: content-box;
  block-size: 150px;
  padding-block: 20px;
  border-block: solid #1769aa;
  border-block-width: 8px 2px;
}

The content box is 150 pixels along the block axis. The block-axis padding adds 40 pixels, and the borders add 10 pixels, producing a 200-pixel border-box block size.

border-box

.border-box-panel {
  box-sizing: border-box;
  block-size: 150px;
  padding-block: 20px;
  border-block: solid #1769aa;
  border-block-width: 8px 2px;
}

The declared 150-pixel block size includes the content, block-axis padding, and borders.

Reserving Border Space

.interactive-panel {
  border-block: 4px solid transparent;
}
.interactive-panel:hover {
  border-block-color: #1769aa;
}

The transparent borders reserve space before hover. Changing only their colors avoids changes to border thickness.

Animating Border Width

.animated-panel {
  border-block: 2px solid #1769aa;
  transition: border-block-start-width 200ms ease;
}
.animated-panel:hover {
  border-block-start-width: 6px;
}
@media (prefers-reduced-motion: reduce) {
  .animated-panel {
    transition: none;
  }
}

The block-start width transitions from 2 to 6 pixels. Changing border widths can affect layout, so consider reserving space or animating color when a stable layout is important.

Practical Uses

The property is useful for controlling logical section dividers, decorative borders, and component accents.

Matching Section Borders

.content-section {
  border-block: solid #d0d7de;
  border-block-width: 1px;
  padding-block: 20px;
}

Both logical block borders use the same subtle thickness.

Emphasized Start Border

.feature-panel {
  border-block: solid #1769aa;
  border-block-width: 6px 2px;
  padding-block: 16px;
}

The thicker block-start border creates a stronger visual accent.

Different Border Styles and Widths

.summary-section {
  border-block-color: #1769aa;
  border-block-style: double solid;
  border-block-width: 6px 2px;
  padding-block: 20px;
}

The block-start border is a 6-pixel double line, while the block-end border is a 2-pixel solid line.

Custom Properties

.themed-panel {
  --start-width: 6px;
  --end-width: 2px;
  border-block: solid #1769aa;
  border-block-width: var(--start-width) var(--end-width);
}

Custom properties make it easier to reuse consistent border widths across related components.

border-block-width Example

The following example compares equal and different logical block border widths and demonstrates how those widths map to vertical writing modes.

<div class="border-block-width-demo">
  <div class="demo-item">
    <p>Equal Widths</p>
    <div class="demo-box equal">4px</div>
  </div>
  <div class="demo-item">
    <p>Different Widths</p>
    <div class="demo-box different">8px 2px</div>
  </div>
  <div class="demo-item">
    <p>vertical-rl</p>
    <div class="demo-box vertical-right">8px 2px</div>
  </div>
  <div class="demo-item">
    <p>vertical-lr</p>
    <div class="demo-box vertical-left">8px 2px</div>
  </div>
</div>
.border-block-width-demo {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 20px;
}
.border-block-width-demo .demo-item {
  padding: 8px;
}
.border-block-width-demo .demo-item p {
  margin-bottom: 10px;
  font-weight: bold;
}
.border-block-width-demo .demo-box {
  box-sizing: border-box;
  inline-size: 170px;
  block-size: 110px;
  padding: 15px;
  border-block-style: solid;
  border-block-color: #1769aa;
  background-color: #e8f2fb;
  color: #173b5e;
  font-weight: bold;
  text-align: center;
}
.border-block-width-demo .equal {
  border-block-width: 4px;
}
.border-block-width-demo .different {
  border-block-width: 8px 2px;
}
.border-block-width-demo .vertical-right {
  writing-mode: vertical-rl;
  border-block-width: 8px 2px;
}
.border-block-width-demo .vertical-left {
  writing-mode: vertical-lr;
  border-block-width: 8px 2px;
}
Browser Result

Equal Widths

4px

Different Widths

8px 2px

vertical-rl

8px 2px

vertical-lr

8px 2px

The first box uses one value, so its top and bottom borders are both 4 pixels thick.

The second box uses two values, producing an 8-pixel top border and a 2-pixel bottom border.

The third box uses vertical-rl, so the right border is 8 pixels thick and the left border is 2 pixels thick.

The fourth box uses vertical-lr, so the left border is 8 pixels thick and the right border is 2 pixels thick.

All four boxes use logical border widths that follow the element's writing mode.

Important Considerations

Keep the following points in mind when using border-block-width:

  • Shorthand property: Sets the widths of the logical block-start and block-end borders.
  • One value: Applies the same width to both borders.
  • Two values: The first applies to block-start, and the second applies to block-end.
  • Initial value: Both constituent widths initially use medium.
  • Inheritance: The property is not inherited.
  • Writing mode: The physical borders affected depend on writing-mode.
  • Horizontal writing: The property controls the top and bottom border widths.
  • Vertical writing: It controls the left and right border widths according to block flow.
  • Width keywords: thin, medium, and thick use browser-defined thicknesses.
  • Length values: Nonnegative CSS lengths are supported.
  • Invalid values: Negative lengths, percentages, and more than two width values are invalid.
  • Zero width: A value of 0 removes the thickness of the corresponding border.
  • Border styles: Borders with style none or hidden have a used width of zero.
  • Border colors: This shorthand does not change the specified border colors.
  • Longhand properties: Use border-block-start-width or border-block-end-width to control one side.
  • Broader shorthand: Use border-block to set widths, styles, and colors together.
  • Physical borders: Logical and physical declarations may target the same edges depending on writing mode.
  • Shorthand overrides: Later border shorthands may reset these widths.
  • Box model: The used border widths contribute to the element's dimensions.
  • Animation: Border widths animate as lengths, but changes may affect layout.

Use border-block-width when both logical block border widths should be controlled together without resetting their styles or colors.

Browser Support

The border-block-width property is widely supported in modern versions of Chrome, Edge, Firefox, Safari, and other major browsers.

The standard property does not require vendor prefixes. Support for CSS math functions used in width values may vary independently.

Standard Declaration

.panel {
  border-block-style: solid;
  border-block-color: #1769aa;
  border-block-width: 8px 2px;
}

Physical Border Fallback

.panel {
  border-top: 8px solid #1769aa;
  border-bottom: 2px solid #1769aa;
}
@supports (border-block-width: 8px 2px) {
  .panel {
    border-top: 0;
    border-bottom: 0;
    border-block: solid #1769aa;
    border-block-width: 8px 2px;
  }
}

This fallback assumes horizontal writing mode. Browsers supporting logical borders use the block-start and block-end borders, while older browsers retain the physical top and bottom borders.

For vertical writing modes, physical fallbacks must be adapted to the appropriate left and right sides.

Visit Can I Use? and search for border-block-width to review current browser compatibility.

Specifications

The border-block-width property is defined in the CSS Logical Properties and Values Module Level 1 specification.

CSS Logical Properties and Values Module Level 1

General border-width behavior is defined in the CSS Backgrounds and Borders Module Level 3 specification.

CSS Backgrounds and Borders Module Level 3