CSS Logical Properties
CSS Logical Properties replace physical top/right/bottom/left with flow-relative block-start/inline-end/block-end/inline-start. The style engine resolves them to physical sides based on dir="rtl" and writing-mode, eliminating duplicate RTL stylesheets.
Physical left/right vs Logical inline-start/end
Compare how physical vs logical properties behave under dir="rtl".
.callout {
border-left: 4px solid #3b82f6;
padding-left: 1rem;
text-align: left;
}Border and padding stay stuck on the left in Arabic/Hebrew.
.callout {
border-inline-start: 4px solid #3b82f6;
padding-inline-start: 1rem;
text-align: start;
}Automatically mirrors to the right when dir="rtl" is set.
Under the Hood
Physical directions assume every reader scans left-to-right from top-to-bottom; logical properties orient themselves to the text stream's inline and block axes during Render Tree & Layout.
- Axis Mapping: In horizontal
ltr,inline-startmaps toleftandblock-startmaps totop. Flippingdir="rtl"remapsinline-starttorightautomatically. - Shorthands:
margin-inline: 1remsets both start and end;inset: 0sets all fourtop/right/bottom/leftoffsets at once. - Radius & Overflow:
border-start-start-radiusandinline-size/block-sizecomplete the model alongside Block Formatting Context layout.
.drawer {
position: fixed;
inset-block: 0;
inset-inline-end: 0;
inline-size: min(360px, 90vw);
border-inline-start: 1px solid #27272a;
}Problem Genealogy
- 2005–2018: Internationalized apps ran PostCSS RTLCSS build plugins or maintained brittle
[dir="rtl"]override sheets. - 2020+: CSS Logical Properties Level 1 achieved universal support, making single-bundle LTR/RTL/CJK layouts native.
Production Pitfalls
- Mixing physical and logical: Writing
margin-inline: 0abovemargin-left: 1remmaps to the same underlying box-model slot, causing confusing cascade overrides. - Logical
overflow-xgotcha:overflow-inlineis newer thanmargin-inline; verify support before replacingoverflow-xif targeting older browsers.
- When not to use logical properties: Do not use logical directions for inherently physical geometry (like a compass rose or video scrubber bar that always runs left-to-right).
Connections & Logical Next Steps
Logical axes map block and inline directions onto the document’s writing mode.
Resolves inline and block properties to physical box edges during layout box generation.
BFCs isolate vertical margin collapse and floats, whereas logical properties orient box edges to writing mode.