Saltar al contenido principal
← 🎨 CSS as a design system·Módulo B4 · Lección 4
TareaSet body line-height to 1.6, h1 to 1.15. Add some body text and an h1 so the difference is visible.

ritmo de altura de línea: el número que soluciona el 80% del tipo incorrecto

75 XP6 min
Teoría

Unitless line-height is the modern default

body { line-height: 1.5; }        /* unitless — multiplier of element's font-size */

For each element, computed line-height = font-size × 1.5. As font-size changes (responsive), line-height stays proportional. Always use unitless for body.

The numbers that work

Use caseline-height
Body paragraphs1.5 – 1.7
Large hero headlines1.1 – 1.25
Display type / numerals1.0 (tight)
Form inputs / buttons1.0 – 1.2
Code blocks1.4 – 1.6

Below 1.4 on body text feels cramped. Above 1.8 feels loose / disconnected. Stay in the 1.5-1.7 sweet spot.

Why headings need TIGHTER line-height

A 48px hero headline at line-height 1.5 becomes 72px tall lines — feels like a wall. Tighten to 1.1-1.25 so a 2-3 line headline feels like one visual unit.

h1, h2 { line-height: 1.15; }
body { line-height: 1.6; }

NEVER set line-height in px

/* DON'T */
body { line-height: 24px; }      /* breaks when font-size changes */

/* DO */
body { line-height: 1.5; }       /* scales with font-size */

The unitless number is the gift CSS gave us in 1998 and ignored for 20 years. Use it.

🔒

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.