Introduction to Logical Properties and Flow-Relative Values
What you'll learn: How to write CSS that automatically adapts to different writing directions without hardcoding left/right or top/bottom positions.
Why Physical Properties Fall Short
Traditionally, CSS uses physical properties like margin-left, padding-right, border-top, and text-align: left. These work fine for English and other left-to-right (LTR) languages. But what happens when your site needs to support Arabic, Hebrew (right-to-left), or Japanese (sometimes vertical)?
Physical properties break down because "left" doesn't mean "start" in all languages. If you set margin-left: 20px to indent the beginning of a paragraph, that margin appears on the wrong side in RTL languages.
Enter Logical Properties
Logical properties use flow-relative directions instead of physical ones:
margin-inline-startinstead ofmargin-left(adapts to text direction)margin-inline-endinstead ofmargin-rightmargin-block-startinstead ofmargin-top(adapts to writing mode)margin-block-endinstead ofmargin-bottom
Think of inline as "along the reading direction" (horizontal in English, vertical in some Japanese layouts) and block as "perpendicular to reading" (vertical in English, stacking paragraphs).
The Power of Adaptation
When you use padding-inline-start: 1rem, it automatically becomes left padding in LTR contexts and right padding in RTL contexts—no extra code needed. The browser handles the adaptation based on the document's dir attribute or CSS direction property.
This approach makes internationalization effortless and keeps your CSS clean and maintainable.
Key Takeaway: Logical properties replace physical directions (left/right/top/bottom) with flow-relative terms (inline-start/inline-end/block-start/block-end) that automatically adapt to different writing modes and text directions.