Writing Modes and Direction
You'll learn how writing-mode and direction properties fundamentally change the meaning of logical properties across different languages and layouts.
The Core Idea
While logical properties define spacing and positioning relative to the inline and block axes, the writing-mode and direction properties actually change which physical directions those axes represent. Different languages flow differently—English flows left-to-right and top-to-bottom, but Arabic flows right-to-left, and traditional Japanese can flow top-to-bottom and right-to-left.
The writing-mode Property
The writing-mode property controls whether text flows horizontally or vertically:
horizontal-tb(default): text flows horizontally, top to bottomvertical-rl: text flows vertically, right to left (like traditional Japanese)vertical-lr: text flows vertically, left to right (like Mongolian)
When you change writing modes, block and inline axes swap. In vertical-rl, the inline axis runs vertically and the block axis runs horizontally.
The direction Property
The direction property controls the inline direction within horizontal text:
ltr(default): left-to-rightrtl: right-to-left (Arabic, Hebrew)
When direction is rtl, margin-inline-start means the right side, not the left.
Why This Matters for Logical Properties
This is why logical properties are so powerful. If you write margin-inline-start: 1rem, that margin automatically adjusts to the correct physical edge based on the writing mode and direction—no extra code needed for internationalization.
Key Takeaway: The writing-mode and direction properties redefine which physical edges correspond to logical properties, enabling truly language-agnostic CSS that adapts automatically to different writing systems.