Write layout that flows, not that hard-codes sides
CSS logical properties describe boxes by their relationship to the text flow — block and inline axes, start and end edges — instead of fixed top, right, bottom, left. This lets one stylesheet adapt to right-to-left and vertical writing modes automatically. This reference maps each logical property to its physical equivalent and resolves which physical side it becomes for any writing mode.
How it works
Two axes replace the four physical sides. The inline axis follows the direction text runs; the block axis follows the direction lines stack. Each has a start and an end:
/* physical, breaks in RTL */
margin-left: 1rem;
/* logical, flips automatically */
margin-inline-start: 1rem;
The resolution depends on writing-mode and direction. In horizontal-tb + ltr,
inline-start = left and block-start = top. Switch to direction: rtl and inline-start
becomes right. Switch to writing-mode: vertical-rl and block-start becomes the right
edge while inline-start becomes the top.
Axis resolution table
| writing-mode | direction | block-start | block-end | inline-start | inline-end |
|---|---|---|---|---|---|
| horizontal-tb | ltr | top | bottom | left | right |
| horizontal-tb | rtl | top | bottom | right | left |
| vertical-rl | ltr | right | left | top | bottom |
| vertical-lr | ltr | left | right | top | bottom |
Common physical-to-logical conversions
| Physical property | Logical equivalent |
|---|---|
margin-top | margin-block-start |
margin-left | margin-inline-start |
padding-right | padding-inline-end |
border-bottom | border-block-end |
top, left (positioned) | inset-block-start, inset-inline-start |
width | inline-size |
height | block-size |
max-width | max-inline-size |
The shorthands collapse two edges: margin-inline: auto centres the element
horizontally in ltr and rtl equally, replacing the common margin-left: auto; margin-right: auto pattern.
Practical migration tips
Start at the layout level. The highest-leverage swap is replacing margin-left
and padding-left with their logical equivalents on navigation items, form labels
and list indentation — these are the first things to break in an RTL layout.
Use inset for positioned elements. The inset shorthand is the logical
equivalent of setting all four edges at once. inset: 0 replaces
top: 0; right: 0; bottom: 0; left: 0. Use inset-inline-start and
inset-block-start to position relative to the text flow rather than the screen.
text-align: start replaces text-align: left — it aligns to wherever the
line begins regardless of direction.
Tips and notes
- Use the
*-inline/*-blockshorthands (margin-inline: 1rem) for both edges at once. inset-inline-start/inset-block-endreplaceleft/bottomfor positioned boxes.- Logical properties remove most
[dir="rtl"]overrides from your stylesheet. text-align: startandfloat: inline-endare the logical equivalents ofleft/right.- Mixing logical and physical on the same side leads to cascade surprises — pick one system per component.