← CodeClarityLab Home
Browse by Category
+ added · updated 7d
← Back to glossary

CSS Logical Properties

frontend CSS4 Intermediate

Also Known As

logical properties inline start block start RTL CSS LTR

TL;DR

CSS properties that map to physical directions based on writing mode — margin-inline instead of margin-left/right, padding-block instead of padding-top/bottom — enabling RTL support automatically.

Explanation

CSS logical properties replace directional properties with flow-relative equivalents: inline (horizontal in LTR, vertical in TTB) and block (vertical in LTR, horizontal in TTB). margin-inline-start replaces margin-left (automatically becomes margin-right in RTL). padding-block replaces padding-top + padding-bottom. border-inline-end replaces border-right. inset-inline-start replaces left. Use logical properties from the start of a project — retrofitting physical properties for RTL languages requires overriding every physical property in RTL stylesheets.

Common Misconception

RTL support requires a separate RTL stylesheet — using logical properties eliminates the need for a separate RTL override stylesheet; the browser applies the correct physical direction based on the dir attribute.

Why It Matters

A site using margin-left: 16px needs margin-right: 16px in its RTL stylesheet — the same site using margin-inline-start: 16px handles both LTR and RTL automatically with one rule.

Common Mistakes

  • Mixing physical and logical properties — margin-left alongside margin-inline-start causes conflicts.
  • Using logical properties for decorative directional elements — a left-pointing arrow should still be physical.
  • Not setting dir=rtl on the html element for RTL languages — logical properties require a direction context.
  • Browser support gaps — inset-* properties have slightly less support than margin-*/padding-*.

Code Examples

✗ Vulnerable
/* Physical properties — requires RTL override:
.nav-item { margin-left: 16px; border-right: 1px solid; padding-left: 8px; }
/* RTL override needed: */
[dir=rtl] .nav-item { margin-left: 0; margin-right: 16px;
    border-right: none; border-left: 1px solid; padding-left: 0; padding-right: 8px; }
✓ Fixed
/* Logical properties — RTL works automatically:
.nav-item {
    margin-inline-start: 16px;  /* margin-left in LTR, margin-right in RTL */
    border-inline-end: 1px solid; /* border-right in LTR, border-left in RTL */
    padding-inline-start: 8px;
}
/* No RTL override needed — browser handles it based on dir attribute */

Added 16 Mar 2026
Edited 22 Mar 2026
Views 29
Rate this term
No ratings yet
🤖 AI Guestbook educational data only
| |
Last 30 days
0 pings W 0 pings T 0 pings F 0 pings S 0 pings S 1 ping M 0 pings T 0 pings W 0 pings T 0 pings F 1 ping S 0 pings S 1 ping M 1 ping T 0 pings W 0 pings T 0 pings F 1 ping S 1 ping S 0 pings M 0 pings T 1 ping W 0 pings T 0 pings F 1 ping S 0 pings S 0 pings M 0 pings T 0 pings W 0 pings T
No pings yet today
No pings yesterday
Amazonbot 8 Perplexity 7 Google 2 Ahrefs 2 Unknown AI 2 ChatGPT 1
crawler 21 crawler_json 1
DEV INTEL Tools & Severity
🟡 Medium ⚙ Fix effort: Medium
⚡ Quick Fix
Replace margin-left/right with margin-inline-start/end and padding-top/bottom with padding-block-start/end — these flip automatically for RTL languages without extra CSS
📦 Applies To
css CSS4 web
🔗 Prerequisites
🔍 Detection Hints
Separate RTL stylesheet duplicating layout rules; margin-left/right used for directional spacing needing RTL override
Auto-detectable: ✓ Yes stylelint rtlcss
⚠ Related Problems
🤖 AI Agent
Confidence: Low False Positives: Medium ✓ Auto-fixable Fix: Low Context: File

✓ schema.org compliant