CSS Reference ยท Container Queries and Logical Properties
The border-block property
Reference for the CSS border-block shorthand: set width, style and color of both block-axis borders, with live examples and usage notes.
The border-block shorthand draws a border on both sides of the block axis: the top and bottom in horizontal text, or the left and right in vertical text. Like border, it accepts a width, a style and a color in any order, and it sets them for the block-start and block-end sides at once.
To style the two sides differently, use border-block-start and border-block-end. For individual parts, there are also border-block-width, border-block-style and border-block-color.
.section { border-block: 2px solid #888; } .title { border-block-end: 3px double #2a62d9; }
Try it
Syntax
border-block: <'border-block-width'> || <'border-block-style'> || <'border-block-color'>;
- Initial value:
medium none currentcolor(no visible border, because the style isnone) - Applies to: all elements
- Inherited: no
- Animatable: width and color yes; style is discrete
- Computed value: each part as specified, with the width made absolute (0 if the style is
noneorhidden)
Values
| Value | Description |
|---|---|
| Width | A length or thin, medium, thick. Default medium. |
| Style | none, hidden, solid, dashed, dotted, double, groove, ridge, inset, outset. Required for the border to appear. |
| Color | Any color. Defaults to the element's color (currentcolor). |
Usage notes
- A style is required.
border-block: 3px redshows nothing, because the omitted style falls back tonone. - The same value for both sides. The shorthand cannot give start and end different values. Add
border-block-startorborder-block-endafterwards to override one. - Resets omitted parts. Like
border, leaving out the color or width resets that part to its initial value, overriding earlier declarations. - Rounded corners are separate.
border-blockdraws only straight edges; corner shapes come fromborder-radiusor logical corner properties. - Layout effect. Borders take space and add to the element's size unless
box-sizing: border-boxis used.
Browser support
Supported in all current browsers.
Related
border-inlineโ the inline-axis counterpartborderโ the physical shorthand for all four sidesborder-start-start-radiusโ logical corner radius- Logical properties
- Lessons: Borders, Writing modes