Briefly
border
is a logical shorthand property. It creates borders for an element along the inline axis.
The block axis is related to the direction of the content flow. Thus, for Russian and English languages, border
draws borders on the left and right of the element, while for Japanese, it draws them on the top and bottom.
Example
div { border-inline: 5px solid white;}
div { border-inline: 5px solid white; }
How to Understand
border
helps place borders where they need to be, regardless of the language 😎
Let's draw borders using border
and border
:
div { border-left: 7px dashed white; border-right: 7px dashed white;}
div { border-left: 7px dashed white; border-right: 7px dashed white; }
Now, the text will be in Japanese, so let's change the flow and see what happens:
div { writing-mode: vertical-rl; border-left: 7px dashed white; border-right: 7px dashed white;}
div { writing-mode: vertical-rl; border-left: 7px dashed white; border-right: 7px dashed white; }
The language is different, the writing direction is different, but the borders remain the same — on the right and left. This is not very good from the perspective of people who speak different languages. Let's try to fix this with the border
property:
div { writing-mode: vertical-rl; border-inline: 7px dashed white;}
div { writing-mode: vertical-rl; border-inline: 7px dashed white; }
Now everything is logical: the writing style changed its direction, and the borders changed too. Using the logical property fixed the situation.
How It's Written
border
is written just like border
, and it also shortens the same properties. The only difference is that border
in the notation is replaced with border
:
border
— width of the border;- inline - width border
— style of the border;- inline - style border
— color of the border.- inline - color
You can style one of the borders separately, similar to border
and border
:
border
— the first border in the inline axis direction;- inline - start border
— the second border.- inline - end
Hints
💡 When you need visible borders of a block to be placed in the direction of the block axis, use the border
property.
div { border-block: 5px solid white;}
div { border-block: 5px solid white; }