Comfortable text comes from two numbers working together: a unitless CSS line height that gives each line room to breathe, and a type scale that keeps every heading and paragraph tied to the same rhythm. Get those right and a page reads calmly at any width; get them wrong and even correct words feel tiring.
The previous lesson in this module covered "How Do System Stacks and Web Fonts Load Fast?", and the next lesson in this module is about "How Does Contrast Guide Both Design and Accessibility?".
Why should line height be a unitless number?
line-height accepts a length, a percentage or a plain number, and the difference shows up the moment a child element changes its own font size.
Write line-height: 1.6 and the browser multiplies that number by the font size of each element it applies to. A paragraph at 1rem gets 1.6rem of leading; a heading at 2.5rem inside the same container gets 4rem of leading. Write line-height: 24px instead and that 24px is inherited as a fixed length, so the 2.5rem heading is crammed into 24px of space and the lines collide.
/* inherits as a number, recomputed per element */
body {
font-size: 1rem;
line-height: 1.6;
}
h2 {
font-size: 2.5rem; /* leading becomes 2.5 * 1.6 = 4rem */
line-height: 1.15; /* headings override to stay tight */
}
Because line-height is inherited, the sensible pattern is to set one comfortable value on the container and let each block of text override it. Body copy sits around 1.5 to 1.7, headings between 1.1 and 1.3, and anything set in a single line can drop to about 1.2 or even 1.
What line length and line height go together?
Long lines are tiring because the eye loses the return sweep from the end of one line to the start of the next. The widely used target is somewhere between 45 and 75 characters per line for continuous reading, and line height matters just as much: if the leading is too tight, the eye cannot isolate one line from the next even when the measure is right.
The ch unit measures the width of the zero glyph, which in most text faces is a little wider than the average lowercase letter, so it is a reasonable stand-in for character count.
.story {
max-width: 65ch;
margin-inline: auto;
font-size: 1.0625rem;
line-height: 1.65;
}
These two numbers pull against each other, so adjust them together. If you narrow the measure to 55ch you can afford slightly tighter leading, because each line returns sooner. If you widen it to 80ch, add a little vertical space to keep the paragraph legible.
How do you build a type scale?
A type scale is simply a set of related sizes. The tidy version multiplies the previous size by a fixed ratio, so every step is the same visual distance from the one below it.
:root {
--ratio: 1.25;
--step--1: calc(1rem / var(--ratio));
--step-0: 1rem;
--step-1: calc(1rem * var(--ratio));
--step-2: calc(1rem * var(--ratio) * var(--ratio));
--step-3: calc(1rem * var(--ratio) * var(--ratio) * var(--ratio));
--step-4: calc(1rem * var(--ratio) * var(--ratio) * var(--ratio) * var(--ratio));
}
body { font-size: var(--step-0); }
.lede { font-size: var(--step-1); }
.headline { font-size: var(--step-3); }
The ratio is a design choice as much as a technical one. Around 1.2 gives a quiet hierarchy for dense interfaces, 1.25 to 1.33 suits editorial work, and anything above 1.5 makes the jumps dramatic enough that you should only use two or three steps.
| Step | Multiplier | rem | px at a 16px root |
|---|---|---|---|
| -1 | 0.8 | 0.8rem | 12.8 |
| 0 | 1 | 1rem | 16 |
| 1 | 1.25 | 1.25rem | 20 |
| 2 | 1.5625 | 1.5625rem | 25 |
| 3 | 1.953 | 1.953rem | 31.25 |
| 4 | 2.441 | 2.441rem | 39.06 |
Write the steps out as custom properties once and every heading level becomes a one-word change. If a designer asks for a slightly larger title, you adjust one variable instead of hunting through a stylesheet.
How do you make a type scale fluid?
A fixed scale looks wrong at the extremes. On a narrow phone a 39px headline eats the screen, and on a wide monitor a 16px paragraph is unreadably small. clamp() solves this by giving each size a floor, a preferred fluid value and a ceiling.
:root {
--step-0: clamp(0.95rem, 0.9rem + 0.25vw, 1.1rem);
--step-1: clamp(1.15rem, 1rem + 0.6vw, 1.45rem);
--step-2: clamp(1.4rem, 1.1rem + 1.2vw, 2rem);
--step-3: clamp(1.7rem, 1.2rem + 2.2vw, 3rem);
}
h1 { font-size: var(--step-3); line-height: 1.12; }
h2 { font-size: var(--step-2); line-height: 1.18; }
The middle value is a fixed part plus a viewport part, which is what makes it fluid. The floor matters more than people expect: without it, a very small viewport would shrink the type past the point of legibility. Because the floor and the ceiling are written in rem rather than pixels, they grow along with the root font size when a reader zooms the text up, so the scale stays readable at any magnification.
How do headings, spacing and rhythm fit together?
Sizes alone are not enough. The space above and below a heading should relate to the size of the heading, or the page reads as a pile of unrelated blocks. A simple approach is a spacing unit derived from the body line height, and margins expressed as multiples of it.
<article class="story">
<p class="kicker">Environment</p>
<h1>The river that stopped flooding on its own</h1>
<p class="lede">Engineers gave the channel room to move, and the water found its own path home.</p>
<h2>What changed on the banks</h2>
<p>The old embankment held the river in a straight line until it broke.</p>
</article>
.story {
--space: 1.5rem;
--measure: 65ch;
max-width: var(--measure);
}
.story h1 { font-size: var(--step-3); margin-block: 0 var(--space); }
.story h2 { font-size: var(--step-2); margin-block: calc(var(--space) * 2) var(--space); }
.story p { margin-block: 0 var(--space); }
.kicker {
font-size: var(--step--1);
letter-spacing: 0.08em;
text-transform: uppercase;
}
Long headings deserve one more touch. Where browsers support text-wrap: balance, a heading spreads its words evenly across the lines instead of leaving a lonely last word, which removes the most common typographic complaint on the web. The same idea applied to paragraphs is text-wrap: pretty, supported in some browsers, which improves the raggedness of the final line.
The short version
- Write line height as a number so every element scales its own leading from its own font size.
- Body copy reads best around 1.5 to 1.7 leading with a measure of roughly 45 to 75 characters.
- Build sizes from one base and one ratio, then store them as custom properties.
- Use
clamp()to let the scale breathe between a floor and a ceiling instead of jumping at breakpoints. - Derive spacing from the same rhythm so the gaps between blocks match the type that fills them.
- Balance heading lines and keep the measure independent of the font size so text never runs edge to edge.
Try it yourself: Pick a base of 1rem and a ratio of 1.25, then write out five steps as custom properties on :root. Set an article to a 65ch measure with a 1.65 line height, apply the steps to the kicker, heading, subheading and body, and convert the fixed steps to clamp() values. Resize the window slowly from 360px to 1600px and confirm that no line of body text ever exceeds about 75 characters and no heading ever drops below 1rem.