Saltar al contenido principal
← 🎨 CSS as a design system·Módulo B6 · Lección 9
TareaStyle .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.

Propiedades lógicas: margen en línea, bloque de relleno

75 XP6 min
Teoría

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.

🔒

Regístrate para empezar a programar

La teoría está abierta a todos. El editor, la vista previa y el check se desbloquean con una prueba gratis de 7 días — se requiere tarjeta, cancela cuando quieras.

Registrarse — prueba gratis →

Las primeras 10 lecciones de cada ruta son gratis. No se necesita tarjeta.

← AnteriorSiguiente lección →

Recibe un consejo de Python o web al día — por email

Corto, escrito a mano, sin spam. Anula la suscripción en un clic.