CSS border-block Property
The border-block shorthand property sets the width, style, and color of an element's borders on its logical block-start and block-end sides.
Unlike physical border properties, border-block follows the element's writing mode. It normally controls the top and bottom borders in horizontal writing modes and the left and right borders in vertical writing modes.
border-block Syntax
selector {
border-block: 2px solid #1769aa;
}
The shorthand accepts a border width, style, and color. These components can appear in any order.
.complete {
border-block: 3px solid blue;
}
.width-and-style {
border-block: 4px dashed;
}
.style-and-color {
border-block: dotted red;
}
.style-only {
border-block: solid;
}
.no-border {
border-block: none;
}
The following declarations are equivalent:
.first {
border-block: 2px solid red;
}
.second {
border-block: solid red 2px;
}
.third {
border-block: red 2px solid;
}
CSS-wide values are also supported.
.example {
border-block: inherit;
border-block: initial;
border-block: revert;
border-block: revert-layer;
border-block: unset;
}
These declarations illustrate the available global values. In an actual stylesheet, use the value appropriate for the intended cascade behavior.
The border-block shorthand applies the same width, style, and color to both logical block sides. To specify different values for each side, use border-block-start and border-block-end.
Property Values
| Value | Description |
|---|---|
<line-width> |
Sets the thickness of both block borders using a nonnegative length or the thin, medium, or thick keyword. |
<line-style> |
Sets the border style using values such as solid, dashed, dotted, or double. |
<color> |
Sets the color of both borders using a valid CSS color value. |
none |
Specifies no visible border line. This is a border-style value. |
hidden |
Suppresses the border and has special behavior when resolving collapsed table borders. |
The initial values of the constituent properties are medium for width, none for style, and currentColor for color.
The property is not inherited. Its constituent properties have their own computed values and animation behavior.
How border-block Works
CSS defines logical sides according to the inline and block axes of an element's writing mode.
The block axis is the direction in which lines of text are stacked. The block-start side is where the block progression begins, and the block-end side is where it ends.
Applying Both Block Borders
.panel {
border-block: 3px solid #1769aa;
}
This declaration applies a 3-pixel solid blue border to both the block-start and block-end sides.
It is equivalent to:
.panel {
border-block-start: 3px solid #1769aa;
border-block-end: 3px solid #1769aa;
}
Expanded Longhand Properties
The shorthand sets six logical border longhands.
.panel {
border-block-start-width: 3px;
border-block-start-style: solid;
border-block-start-color: #1769aa;
border-block-end-width: 3px;
border-block-end-style: solid;
border-block-end-color: #1769aa;
}
A Border Style Is Required
.invisible {
border-block: 3px red;
}
.visible {
border-block: 3px solid red;
}
The first declaration does not display a border because the omitted style resets to none. The second declaration displays the borders.
The Shorthand Resets Existing Block Borders
.panel {
border-block-start: 6px dashed red;
border-block: 2px solid blue;
}
The later shorthand replaces the earlier block-start border and applies the same 2-pixel solid blue border to both block sides.
Writing Modes and Border Mapping
The physical sides affected by border-block depend on the element's writing-mode.
| 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-panel {
writing-mode: horizontal-tb;
border-block: 3px solid #1769aa;
}
The borders appear at the physical top and bottom of the element.
Vertical Writing Mode
.vertical-panel {
writing-mode: vertical-rl;
border-block: 3px solid #1769aa;
}
The borders appear at the physical right and left sides of the element.
Text Direction
The direction property controls inline text direction. Changing it from ltr to rtl does not reverse the block-start and block-end sides in horizontal-tb.
.right-to-left-panel {
direction: rtl;
writing-mode: horizontal-tb;
border-block: 2px solid #1769aa;
}
The borders remain on the top and bottom sides.
Border Block Width
The width component controls the thickness of both block borders.
Length Values
.thin-line {
border-block: 1px solid #1769aa;
}
.medium-line {
border-block: 3px solid #1769aa;
}
.thick-line {
border-block: 6px solid #1769aa;
}
Nonnegative CSS lengths such as px, em, and rem are valid. Percentages and negative widths are invalid.
Width Keywords
.thin-border {
border-block: thin solid #1769aa;
}
.medium-border {
border-block: medium solid #1769aa;
}
.thick-border {
border-block: thick solid #1769aa;
}
The browser determines the exact thickness of the thin, medium, and thick keywords.
Using border-block-width
.panel {
border-block: solid #1769aa;
border-block-width: 4px;
}
The first declaration establishes the border style and color. The second sets the width of both block borders.
Different Widths for Each Side
.panel {
border-block: solid #1769aa;
border-block-start-width: 2px;
border-block-end-width: 6px;
}
Use the individual logical side properties when the two block borders require different thicknesses.
Border Block Style
The style component determines the appearance of the block-start and block-end borders.
| Value | Appearance |
|---|---|
none |
No border line. |
hidden |
No visible line, with special collapsed table behavior. |
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 or carved appearance. |
ridge |
A raised or embossed appearance. |
inset |
An appearance suggesting the element is pressed inward. |
outset |
An appearance suggesting the element is raised outward. |
Common Styles
.solid-example {
border-block: 4px solid #1769aa;
}
.dashed-example {
border-block: 4px dashed #1769aa;
}
.dotted-example {
border-block: 4px dotted #1769aa;
}
.double-example {
border-block: 6px double #1769aa;
}
Different Styles on Each Side
.panel {
border-block: 3px solid #1769aa;
border-block-end-style: dashed;
}
The block-start border remains solid, while the block-end border becomes dashed.
Use border-block-style when both sides share the same style, or the individual side longhands when different styles are needed.
Border Block Color
The color component determines the color of both block borders.
Named Colors
.named-color {
border-block: 3px solid navy;
}
Hexadecimal Colors
.hex-color {
border-block: 3px solid #1769aa;
}
RGB Colors
.rgb-color {
border-block: 3px solid rgb(23 105 170);
}
Using currentColor
.matching-color {
color: #1769aa;
border-block: 3px solid currentColor;
}
The currentColor keyword uses the element's computed text color. It is also the initial border color when no color is specified.
Transparent Borders
.transparent-border {
border-block: 3px solid transparent;
}
The borders remain part of the box model but are not visibly painted.
Different Colors for Each Side
.two-color-panel {
border-block: 3px solid #1769aa;
border-block-end-color: #d35400;
}
The block-start border remains blue, while the block-end border becomes orange.
Alternatively, use border-block-color with one or two color values to set both logical sides directly.
Omitted Values and Defaults
Each omitted component of the border-block shorthand resets to its initial value.
| Component | Initial Value |
|---|---|
| Width | medium |
| Style | none |
| Color | currentColor |
Omitting Width
.example {
border-block: solid blue;
}
The width is reset to medium.
Omitting Color
.example {
color: #1769aa;
border-block: 2px solid;
}
The border color defaults to currentColor, matching the element's text color.
Omitting Style
.example {
border-block: 2px blue;
}
The border style is reset to none, so no visible border appears.
Removing Block Borders
.no-block-border {
border-block: none;
}
This resets both block border styles to none, their widths to medium, and their colors to currentColor.
When the border style is none, the used border width is zero.
Styling Individual Block Sides
The border-block-start and border-block-end properties provide independent control over the two logical block sides.
Block-Start Border
.start-border {
border-block-start: 4px solid #1769aa;
}
In horizontal writing mode, this border appears at the top. In vertical-rl, it appears on the right.
Block-End Border
.end-border {
border-block-end: 4px solid #1769aa;
}
In horizontal writing mode, this border appears at the bottom. In vertical-rl, it appears on the left.
Different Borders on Each Side
.section-heading {
border-block-start: 2px solid #c5d8e8;
border-block-end: 5px solid #1769aa;
padding-block: 12px;
}
The two borders have different widths and colors while continuing to follow the writing mode.
Overriding One Side
.panel {
border-block: 2px solid #1769aa;
border-block-end: 5px dashed #d35400;
}
The first declaration sets both block borders. The second changes only the block-end border.
Place individual side overrides after the shorthand when they should take precedence at the same cascade priority.
border-block vs. border-inline
The border-block and border-inline properties control different logical sides of an element.
| Property | Horizontal Writing | Vertical Writing |
|---|---|---|
border-block |
Top and bottom | Left and right |
border-inline |
Left and right | Top and bottom |
Block Borders
.block-borders {
border-block: 3px solid #1769aa;
}
Inline Borders
.inline-borders {
border-inline: 3px solid #1769aa;
}
Combining Both Properties
.all-logical-borders {
border-block: 3px solid #1769aa;
border-inline: 1px dashed #65a6c9;
}
This example gives the block sides a solid blue border and the inline sides a thinner dashed border.
Because the declarations use logical properties, the styling follows the element's writing mode without requiring separate physical border rules.
Logical vs. Physical Borders
Physical border properties always refer to the top, right, bottom, or left side of an element. Logical border properties map to physical sides according to writing mode and direction.
Physical Borders
.physical-panel {
border-top: 2px solid #1769aa;
border-bottom: 2px solid #1769aa;
}
The borders remain on the physical top and bottom sides, regardless of writing mode.
Logical Borders
.logical-panel {
border-block: 2px solid #1769aa;
}
The borders follow the block-start and block-end sides.
Mixing Logical and Physical Declarations
.panel {
border-top: 4px solid red;
border-block-start: 2px solid blue;
}
In horizontal writing mode, both declarations target the physical top border. At equal cascade priority, the later logical declaration wins.
In vertical-rl, border-block-start targets the physical right border, so the two declarations affect different sides.
Using a Physical Fallback
.panel {
border-top: 2px solid #1769aa;
border-bottom: 2px solid #1769aa;
border-block: 2px solid #1769aa;
}
The physical declarations provide a fallback for horizontal writing layouts in browsers without logical border support.
For multilingual layouts, prefer logical properties consistently and test any combination of physical and logical declarations.
Borders and the Box Model
Logical borders occupy the same border area as physical borders. They contribute to an element's dimensions according to the CSS box model.
The content-box Model
.content-box-panel {
box-sizing: content-box;
block-size: 150px;
padding-block: 20px;
border-block: 5px solid #1769aa;
}
The element has a content block size of 150 pixels. The block-axis padding adds 40 pixels, and the two borders add 10 pixels, producing a 200-pixel border-box block size.
The border-box Model
.border-box-panel {
box-sizing: border-box;
block-size: 150px;
padding-block: 20px;
border-block: 5px solid #1769aa;
}
The declared 150-pixel block size includes the content, padding, and block borders.
Using Transparent Borders
.interactive-panel {
border-block: 3px solid transparent;
}
.interactive-panel:hover {
border-block-color: #1769aa;
}
The transparent borders reserve space before the hover state. Changing their color does not change their thickness.
Rounded Corners
.rounded-panel {
border-block: 3px solid #1769aa;
border-radius: 12px;
}
The border-radius property rounds the element's border corners. It is separate from border-block and is not reset by this shorthand.
border-block Example
The following example compares border-block in horizontal and vertical writing modes.
Both boxes use the same logical border declaration. Only the writing mode changes, causing the borders to appear on different physical sides.
<div class="border-block-demo">
<div class="demo-item">
<p>horizontal-tb</p>
<div class="demo-box horizontal">Block borders</div>
</div>
<div class="demo-item">
<p>vertical-rl</p>
<div class="demo-box vertical">Block borders</div>
</div>
<div class="demo-item">
<p>vertical-lr</p>
<div class="demo-box vertical-left">Block borders</div>
</div>
</div>
.border-block-demo {
display: flex;
flex-wrap: wrap;
align-items: flex-start;
gap: 24px;
}
.border-block-demo .demo-item {
padding: 10px;
}
.border-block-demo .demo-item p {
margin-bottom: 10px;
font-weight: bold;
}
.border-block-demo .demo-box {
box-sizing: border-box;
inline-size: 180px;
block-size: 120px;
padding: 15px;
border-block: 6px solid #1769aa;
background-color: #e8f2fb;
color: #173b5e;
text-align: center;
font-weight: bold;
}
.border-block-demo .horizontal {
writing-mode: horizontal-tb;
}
.border-block-demo .vertical {
writing-mode: vertical-rl;
}
.border-block-demo .vertical-left {
writing-mode: vertical-lr;
}
horizontal-tb
vertical-rl
vertical-lr
In horizontal-tb, the borders appear at the top and bottom of the box.
In vertical-rl, the block-start border is on the right and the block-end border is on the left.
In vertical-lr, the block-start border is on the left and the block-end border is on the right.
The shorthand applies the same styling to both block sides, so the difference between the vertical examples is most noticeable when using separate block-start and block-end styles.
Important Considerations
Keep the following points in mind when using border-block:
- Logical shorthand: The property sets border width, style, and color on the block-start and block-end sides.
- Writing mode: The affected physical sides depend on the element's
writing-mode. - Horizontal writing: The property normally controls the top and bottom borders.
- Vertical writing: The property normally controls the left and right borders.
- Equal styling: Both block sides receive the same width, style, and color from the shorthand.
- Component order: Width, style, and color can appear in any order.
- Initial values: Omitted components reset to
medium,none, andcurrentColor. - Visible style: A visible border style is required for the border to appear.
- Width values: Nonnegative lengths and the
thin,medium, andthickkeywords are supported. - No percentage widths: Percentage values are invalid as border widths.
- Color: The border color defaults to
currentColorwhen omitted. - Individual sides: Use
border-block-startandborder-block-endfor different borders. - Other logical sides: Use
border-inlineto style the inline-start and inline-end sides. - Physical borders: Logical and physical border declarations can affect the same physical side, depending on writing mode.
- Cascade order: Later declarations can override earlier declarations that target the same border longhands.
- Box model: Border thickness contributes to an element's dimensions according to
box-sizing. - Transparent borders: Transparent borders can reserve space for hover or other interactive states.
- Border radius: The
border-radiusproperty is separate and is not reset byborder-block. - Animation: Border widths and colors can animate, while changes between border styles are discrete.
- Accessibility: Borders that communicate important information should remain distinguishable from their surrounding backgrounds.
Use border-block when both logical block sides should share the same border styling. For different block-start and block-end borders, use the individual logical side properties.
Browser Support
The border-block property has Baseline Widely available status and is supported in modern versions of Chrome, Edge, Firefox, Safari, and other major browsers.
Logical border properties do not require vendor prefixes in modern browsers.
Standard Declaration
.panel {
border-block: 2px solid #1769aa;
}
Physical Border Fallback
.panel {
border-top: 2px solid #1769aa;
border-bottom: 2px solid #1769aa;
}
@supports (border-block: 2px solid #1769aa) {
.panel {
border-top: 0;
border-bottom: 0;
border-block: 2px solid #1769aa;
}
}
This example uses physical top and bottom borders as a fallback for horizontal writing. Supporting browsers remove those physical borders and apply the logical block borders instead.
For vertical writing modes, the fallback must be adapted to the appropriate physical sides.
Visit Can I Use? to review current browser compatibility.
Specifications
The border-block shorthand is defined in the CSS Logical Properties and Values Module Level 1 specification.
CSS Logical Properties and Values Module Level 1
General border width, style, and color behavior is defined in the CSS Backgrounds and Borders Module Level 3 specification.
