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.
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.