Zum Hauptinhalt springen
← 🎨 CSS as a design system·Modul B6 · Lektion 9
AufgabeStyle .card using logical properties: margin-inline 16px, padding-block 12px, padding-inline 20px. Set background #f5f5f5 and border-radius 8px. The card should look the same in LTR and RTL.

Logische Eigenschaften: margin-inline, padding-block

75 XP6 min
Theorie

Replace left/right/top/bottom with start/end

/* Physical (LTR-only) */
.card { margin-left: 16px; margin-right: 16px; padding-top: 8px; padding-bottom: 8px; }

/* Logical (RTL-aware) */
.card { margin-inline: 16px; padding-block: 8px; }
  • `-inline` — left/right in LTR languages; right/left in RTL (Arabic, Hebrew).
  • `-block` — top/bottom (vertical, regardless of direction).

Why this matters

If your site supports RTL languages (Arabic, Hebrew, Persian), every margin-left is wrong on those layouts. Logical properties auto-flip.

If your site is LTR-only, logical properties STILL win — shorter syntax, clearer intent (margin-inline: 16px says "horizontal margins" without spelling out which sides).

The full set

PhysicalLogical
margin-leftmargin-inline-start
margin-rightmargin-inline-end
margin-topmargin-block-start
margin-bottommargin-block-end
margin: 8px 16pxmargin: 8px 16px (shorthand still works)
padding-x (none)padding-inline (sets both inline sides)
text-align: lefttext-align: start
border-leftborder-inline-start
left: 0inset-inline-start: 0

Browser support

All evergreen browsers since 2019. Safe everywhere in 2026.

Tailwind uses physical (still)

Tailwind 3.x defaults to ml-4, pt-2, etc. Tailwind 4 (released late 2024) added ms-4 (margin-start), ps-4 (padding-start), text-start. Use the start/end forms in Tailwind 4+ for RTL-ready apps.

🔒

Anmelden, um zu programmieren

Theorie ist für alle offen. Editor, Live-Preview und Check werden mit 7-Tage-Gratis-Test freigeschaltet — Karte erforderlich, jederzeit kündbar.

Registrieren — Gratis-Test →

Die ersten 10 Lektionen jedes Tracks sind kostenlos. Keine Karte nötig.

← ZurückNächste Lektion →

Bekomme einen Python- oder Web-Tipp pro Tag — per E-Mail

Kurz, handgeschrieben, kein Spam. Abmelden mit einem Klick.