Aller au contenu principal
← 🎨 CSS as a design system·Module B6 · Leçon 9
TâcheStyle .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.

Propriétés logiques : margin-inline, padding-block

75 XP6 min
Théorie

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.

🔒

Inscris-toi pour coder

La théorie est ouverte à tous. L'éditeur, l'aperçu live et le check se débloquent avec un essai gratuit de 7 jours — carte requise, annulable à tout moment.

S'inscrire — essai gratuit →

Les 10 premières leçons de chaque parcours sont gratuites. Pas de carte requise.

← PrécédentLeçon suivante →

Recevez une astuce Python ou web par jour — par email

Court, écrit à la main, sans spam. Désabonnement en un clic.