π What Are border-inline & border-block?
border-inline and border-block are **logical border properties** in CSS. They apply borders based on the writing mode (LTR, RTL, vertical) instead of physical directions like border-left or border-top.
- π Writing-mode aware
- β Auto-adjust for RTL languages
- β Adjust for vertical text flows
Note
β Replaces border-left/right/top/bottom
β Great for internationalized UI
π¦ Syntax
border-inline & border-block syntax
border-inline: <width> <style> <color>;
border-inline-start: <width> <style> <color>;
border-inline-end: <width> <style> <color>;
border-block: <width> <style> <color>;
border-block-start: <width> <style> <color>;
border-block-end: <width> <style> <color>;π Understanding Logical Directions
| Logical Side | LTR Equivalent | RTL Equivalent |
|---|---|---|
| inline-start | left | right |
| inline-end | right | left |
| block-start | top | top |
| block-end | bottom | bottom |
π 1. Basic Inline Border
border-inline example
.box {
border-inline: 3px solid #4caf50;
}Equivalent to setting:
border-left & border-right in LTR
Flips automatically for RTL.
π 2. Set Different Start and End Inline Borders
Start & end inline borders
.box {
border-inline-start: 4px solid crimson;
border-inline-end: 4px dashed skyblue;
}π 3. Add Block Borders (Top & Bottom)
border-block example
.card {
border-block: 2px solid gray;
}Equivalent to:
border-top & border-bottom
π 4. Different Block Start & End Borders
block-start-end
.card {
border-block-start: 5px solid #009688;
border-block-end: 5px solid #ff5722;
}π 5. Writing-Mode Aware Borders
Vertical writing mode example
.poem {
writing-mode: vertical-rl;
border-inline: 3px solid orange; /* now top & bottom */
border-block: 3px solid blue; /* now left & right */
}Logical borders automatically switch meaning based on writing mode.
π 6. Full Component Using Logical Borders
Full component example
.panel {
padding: 1rem;
border-block-start: 4px solid #1e88e5;
border-inline-end: 4px solid #e53935;
}Clean, minimal component that adapts globally.
π§ͺ Real-World Use Cases
1οΈβ£ Sidebar That Works in LTR & RTL
Sidebar example
.sidebar {
border-inline-end: 2px solid #ccc;
}In RTL, the border automatically shifts to the left side.
2οΈβ£ Blog Article Divider
Article divider
.article {
border-block-end: 1px solid #ddd;
}3οΈβ£ Form Fields with Consistent Padding & Borders
Form field
.input-field {
border-inline: 1px solid #aaa;
border-block: 1px solid #aaa;
}β οΈ Common Mistakes
- β Using border-left/right instead of logical borders in RTL layouts
- β Forgetting writing-mode affects inline/block directions
- β Over-mixing physical & logical borders β unpredictable layout
Note
π₯ Summary
border-inline andborder-block allow you to create borders that adapt to writing direction and language automatically. They simplify global styling and make your layouts more flexible and future-proof.
Learn more βMDN: border-inline
MDN: border-block π