This is the article page of Stashling, the course’s sample site, at 1280 pixels wide. It ends Module 3 in Inter, the typeface the site now ships.

Figure 1: the article page on a wide screen. Each line runs across almost the whole window.
Here’s the same page on a phone, 390 pixels wide.

Figure 2: the same page on a phone. The lines are short but packed close together.
A reader would say two things. On the laptop, the eye gets lost on the way back from the end of one line to the start of the next. On the phone, the text looks like one dense block, and the title hardly stands out.
This module sets the type: the sizes, the length of a line, the space between lines and between letters, and where lines break. Module 3 chose the typeface; this module decides how it sits on the page at every width.
After this module, you can:
- build a set of font sizes from one base size and one ratio, and say what the ratio costs on a phone
- write sizes in
remwithclamp()so they grow with the screen and still follow the reader’s zoom and font size setting - set a line length in
ch, and check by measuring that it holds the number of characters you meant - set line height and letter spacing by size: more for body text and small capitals, less for large headings
- keep headings clear on a narrow screen with weight and
text-wrap
To follow along, start from the module-03 folder of the course repository, github.com/vespaiach/web-design-course, and open article.html in a browser.
How many characters fit on one line
Open the article page and paste this into the DevTools console. It counts the characters on each line of the first paragraph, by asking the browser where each character was drawn:
const p = document.querySelector("article p:nth-of-type(2)");
const text = p.firstChild;
const range = document.createRange();
const lines = {};
for (let i = 0; i < text.length; i++) {
range.setStart(text, i);
range.setEnd(text, i + 1);
const top = Math.round(range.getClientRects()[0].top);
lines[top] = (lines[top] ?? 0) + 1;
}
console.log(Object.values(lines).join(" "));
The selector skips the date line, which is the article’s first <p>. Characters with the same top edge are on the same line, so the code adds them up by their top edge.
Pause and predict: in Figure 1, about how many characters does one full line of the first paragraph hold? And in Figure 2, on the phone?
Answer
In one run in Chrome 157 on macOS, the page at 1280 px printed this:
145 147 36
At 390 px it printed this:
40 42 38 41 41 38 41 39 8
So a full line holds about 146 characters on the laptop and about 40 on the phone. The phone’s line length is in the range that typographers recommend, as the section on line length shows, so its problem is the space between the lines. But the laptop’s line is more than twice as long as any recommendation.
Both screens show the same CSS. Nothing in it says how long a line may be, how far apart lines sit, or how sizes relate to each other. The next sections set each of those, one at a time.
Fixed steps instead of one-off sizes
The site’s CSS sets six font sizes, each picked when a rule needed one: 14 px for the footer and status labels, 16 px for buttons and fields, 18 px for text, 20 px for h2 and the logo, 24 px for h1, and 40 px for the landing page’s title.
Divide each size by the one below it, and you’ll find the steps are uneven. They’re 16 / 14 = 1.14, 18 / 16 = 1.13, 20 / 18 = 1.11, 24 / 20 = 1.2 and 40 / 24 = 1.67. So an h2 at 20 px is only 11% larger than the text under it.
On the landing page, the feature headings (h3) are 18 px, the same size as the text, so only their bold sets them apart. But Module 1 showed that a difference must be large enough to see.
A type scale is a short, fixed list of font sizes, in which each size is the one below it multiplied by the same number, the ratio. You pick a base size, usually the body text, and a ratio. Then each step up multiplies by the ratio, and each step down divides by it.
Tim Brown brought the idea to the web in 2011 as a “modular scale”, a term that Robert Bringhurst used for type (A List Apart). Calculators name their ratios after musical intervals: 1.125 is a major second, 1.2 a minor third, 1.25 a major third, 1.333 a perfect fourth and 1.5 a perfect fifth. Brown presents the scale as a tool for composing, and says that the math doesn’t replace a designer’s eye. He cites no reading research.
So a type scale is a convention, not a finding. The reason that holds up is the one from Module 1. A few sizes with clear steps between them are easy to tell apart, and a fixed list stops new one-off sizes.
This table shows five ratios from a 16 px base, computed as 16 × ratio^step and rounded to two decimals:
| Step | 1.125 | 1.2 | 1.25 | 1.333 | 1.5 |
|---|---|---|---|---|---|
| -1 | 14.22 | 13.33 | 12.80 | 12.00 | 10.67 |
| 0 | 16 | 16 | 16 | 16 | 16 |
| 1 | 18 | 19.20 | 20 | 21.33 | 24 |
| 2 | 20.25 | 23.04 | 25 | 28.43 | 36 |
| 3 | 22.78 | 27.65 | 31.25 | 37.90 | 54 |
| 4 | 25.63 | 33.18 | 39.06 | 50.52 | 81 |
The ratio has a cost at both ends. With 1.5, step 4 is 81 px, five times the text size, which leaves room for very few letters per line on a phone 375 px wide. But with 1.125, step 1 is 18 px against 16 px text, and the step is hard to see. That’s why large ratios suit wide screens, where a title has room, and small ratios suit phones.
So the usual answer is two ratios, one for a narrow screen and one for a wide one. The default settings of Utopia’s calculator, for example, use 1.2 at a 360 px viewport and 1.25 at 1240 px. The next two sections build that for Stashling.
Rule: Pick a base size and a ratio, and use only the sizes they give. Use a smaller ratio on narrow screens, where large steps run out of room.
Sizes in rem follow the reader’s settings
A reader can make text larger in two ways. Browser zoom scales every CSS unit, px included, and makes the viewport narrower in CSS pixels. But the browser’s default font size setting changes only the root font size, so it changes rem and em and leaves px alone (MDN, length). WCAG’s explanation of Resize Text lists both, as zoom and as text-only resizing (Understanding 1.4.4).
The site sets font-size: 18px on body. To see what that does, set the browser’s default font size to 20 px (in Chrome, Settings, then Appearance, then Customize fonts). Then run this in the console on the article page:
console.log(getComputedStyle(document.documentElement).fontSize,
getComputedStyle(document.body).fontSize);
Pause and predict: the root is now 20 px. What size is the body text?
In one run in Chrome 157, with the default set to 20 px through the DevTools protocol, it printed this:
20px 18px
The reader asked for text 25% larger, and the article ignored it. MDN gives the same reason to prefer relative units, since many users raise the default size and absolute lengths don’t follow it. Set the setting back to its default after this test.
So the course writes every font size in rem. One rem is 16 px at the default, so 1.125 rem is 18 px. Three details matter:
- Leave the root font size to the browser. A rule such as
html { font-size: 16px }locks the root and defeats the setting. Chrome’s guidance on text scaling says the same (Chrome for Developers). Stashling sets its text size onbody, as Module 2 planned. - Some sites set
html { font-size: 62.5% }, so that 1 rem is 10 px. That keeps the setting working, but it changes what 1 rem means everywhere, the spacing scale included. emis relative to the element’s own parent, so it compounds when you nest elements.remdoesn’t.
What changed recently: Chrome 146 added <meta name="text-scale" content="scale">. With it, 1 rem follows the operating system’s text size on Android and ChromeOS, not only the browser setting. Only Chrome and Edge support it, so it’s limited, and without it the page behaves as before. The lab doesn’t add it.
Rule: Write font sizes in
remand leave the root font size alone, so the reader’s font size setting reaches your text.
Fluid sizes with clamp()
The site needs a 1.2 scale on a phone and a 1.25 scale on a laptop. A media query could switch from one to the other at a breakpoint. But then every size jumps at one width, and a screen slightly narrower than the breakpoint gets the small scale at its widest.
Fluid type is a font size that grows in a straight line with the viewport width, between a minimum and a maximum. CSS writes it with clamp(MIN, VAL, MAX), which is the same as max(MIN, min(VAL, MAX)) (CSS Values 4). The middle value is a length in rem plus a share of the viewport in vw.
This script computes Stashling’s scale. Run it with Node.js, or paste it into any browser console:
// A fluid type scale: each step grows in a straight line
// from its size at a 320 px viewport to its size at 1280 px.
const minWidth = 320, minBase = 16, minRatio = 1.2;
const maxWidth = 1280, maxBase = 18, maxRatio = 1.25;
const round = (n) => +n.toFixed(4);
for (let step = -1; step <= 4; step++) {
const min = minBase * minRatio ** step; // px at 320
const max = maxBase * maxRatio ** step; // px at 1280
const slope = (max - min) / (maxWidth - minWidth);
const start = min - slope * minWidth; // px at a 0 px viewport
console.log(
`--step-${step}: clamp(${round(min / 16)}rem, ` +
`${round(start / 16)}rem + ${round(slope * 100)}vw, ${round(max / 16)}rem);` +
` /* ${min.toFixed(2)} to ${max.toFixed(2)} px */`
);
}
At 320 px the scale is 16 px with a ratio of 1.2. At 1280 px it’s 18 px with a ratio of 1.25, so the body text stays at the site’s current 18 px on a laptop. The script prints this:
--step--1: clamp(0.8333rem, 0.8111rem + 0.1111vw, 0.9rem); /* 13.33 to 14.40 px */
--step-0: clamp(1rem, 0.9583rem + 0.2083vw, 1.125rem); /* 16.00 to 18.00 px */
--step-1: clamp(1.2rem, 1.1312rem + 0.3438vw, 1.4063rem); /* 19.20 to 22.50 px */
--step-2: clamp(1.44rem, 1.3341rem + 0.5297vw, 1.7578rem); /* 23.04 to 28.13 px */
--step-3: clamp(1.728rem, 1.5716rem + 0.7821vw, 2.1973rem); /* 27.65 to 35.16 px */
--step-4: clamp(2.0736rem, 1.8493rem + 1.1216vw, 2.7466rem); /* 33.18 to 43.95 px */
Each step is a straight line between two points. The slope is how many pixels of font size the step gains per pixel of viewport. 1vw is 1% of the viewport width, so the slope times 100 is the vw value. The start is where the line would cross a 0 px viewport.
Utopia’s calculator uses the same straight line, so with its default settings, this formula gives the same --step-0 that it prints. Figure 3 draws the six lines.
Figure 3: each step grows from its 320 px size to its 1280 px size, and stays flat outside that range. The steps spread apart because the ratio grows too.
The names follow Utopia’s: --step-0 is the body text, and --step--1 is one step below it. Figure 4 shows the article before and after its sizes move to the scale, at 1280 px.


Figure 4: the old sizes (top) and the type scale (bottom) at 1280 px. Only the font sizes changed.
What fluid type costs at 200% zoom
WCAG 2.2 asks that text can grow to 200% of its size without assistive technology (Success Criterion 1.4.4, Level AA). But viewport units work against that. Zoom makes the viewport narrower in CSS pixels, so a vw value gets smaller as the page zooms in. That’s why WCAG lists font-size in viewport units alone as a failure, F94 (F94).
clamp() with a rem part helps, because the rem part grows with zoom. But whether the text still reaches 200% depends on how far apart the minimum and the maximum are. WCAG’s Understanding document says that one working way to reach 200% is enough, even if it takes more than 200% zoom.
The zoom check, and how it was computed
This script models desktop zoom. At zoom z, a window W px wide shows a viewport of W / z CSS px, and draws every CSS px z times larger. For each step, it compares the size at 100% with the size at 200% zoom, and with the best size up to 500%.
// WCAG 1.4.4: can the text reach twice its size with browser zoom?
// Zoom z shrinks the viewport to W / z CSS px and draws every CSS px z times larger.
const zooms = [1, 1.1, 1.25, 1.5, 1.75, 2, 2.5, 3, 4, 5]; // 100% to 500%
const fluid = (min, max) => (vw) =>
Math.min(max, Math.max(min, min + ((max - min) * (vw - 320)) / (1280 - 320)));
function check(name, size) {
for (const W of [390, 1280, 1920]) {
const normal = size(W);
const at200 = (2 * size(W / 2)) / normal;
const best = Math.max(...zooms.map((z) => z * size(W / z))) / normal;
console.log(`${name} at ${W}: 200% gives ${at200.toFixed(2)}x, best ${best.toFixed(2)}x`,
best >= 2 ? "pass" : "FAIL");
}
}
check("--step-0", fluid(16, 18));
check("--step-4", fluid(16 * 1.2 ** 4, 18 * 1.25 ** 4));
check("16 to 64 px", fluid(16, 64));
It prints this:
--step-0 at 390: 200% gives 1.98x, best 4.95x pass
--step-0 at 1280: 200% gives 1.85x, best 4.44x pass
--step-0 at 1920: 200% gives 1.93x, best 4.48x pass
--step-4 at 390: 200% gives 1.95x, best 4.88x pass
--step-4 at 1280: 200% gives 1.67x, best 3.77x pass
--step-4 at 1920: 200% gives 1.84x, best 3.86x pass
16 to 64 px at 390: 200% gives 1.64x, best 4.10x pass
16 to 64 px at 1280: 200% gives 1.00x, best 1.25x FAIL
16 to 64 px at 1920: 200% gives 1.50x, best 1.50x FAIL
The model ignores layouts that break at high zoom and phone pinch zoom, which doesn’t change the layout. So test with the browser’s own zoom too.
The script’s output says three things. Stashling’s steps pass at every width, because each maximum is at most 1.32 times its minimum. But at exactly 200% zoom, the body text reaches only 1.85 times its size at 1280 px, so a reader needs 250% to double it. A heading from 16 to 64 px, clamp(1rem, 0rem + 5vw, 4rem), fails at 1280 px, because no zoom up to 500% makes it more than 1.25 times larger.
The guidelines differ. MDN suggests a maximum at least twice the minimum, so that the text can reach 200% at all (MDN, clamp).
Maxwell Barvian argues for a maximum at most 2.5 times the minimum, so that zoom still enlarges it enough (Smashing Magazine, 2023). The check above agrees with Barvian’s limit, and shows that a small ratio such as 1.19 passes too. The two rules answer different questions: whether text can reach 200% at all, and whether zoom still enlarges it enough.
The vw part ignores the font size setting, too. With the default font size at 20 px, the lab’s body text is 20 px at 390 px but 21.83 px at 1280 px, not 22.5 px. So the reader gets 21% more instead of 25%. That’s why you should keep the vw part small, as Miriam Suzanne’s article on web.dev suggests (web.dev, 2025).
clamp() is Baseline widely available since 2023-01-28 (Chrome 79, Firefox 75, Safari 13.1). CSS can also compute a scale with pow(), as in calc(1rem * pow(1.25, 2)). It became Baseline widely available on 2026-06-07. But the course keeps the computed numbers, because you can see each size in the token file.
Rule: Make each size fluid with
clamp()and arempart, and keep the maximum within 2.5 times the minimum. Check with real browser zoom.
Line length: set a measure in ch
The measure is the length of a line of text, so in a paragraph it’s also the width of the text block (Google Fonts Knowledge). The article’s measure is the window, minus 20 px of padding.
The recommendations are in characters per line, and they differ:
- Robert Bringhurst: 45 to 75 characters for a single column of serif text, as quoted by Google Fonts.
- Matthew Butterick: an average of 45 to 90 characters, including spaces, because a longer line makes the eye travel farther back to the next line (Practical Typography).
- WCAG 2.2, Success Criterion 1.4.8 (Level AAA): a way for the reader to get lines of no more than 80 characters, or 40 in Chinese, Japanese and Korean. The way can be the browser, so the page doesn’t have to be that narrow (Understanding 1.4.8).
But the research is less clear than these numbers. Mary Dyson’s 2004 review found that most studies on screen report faster reading with longer lines, and that the number of characters per line is what matters (Dyson, 2004). In one study she reports, readers rated 55 characters the easiest, but it wasn’t the fastest. In another, 55 characters gave better understanding than 100.
But readers who struggle get more from short lines. In a 2013 study, high-school students with dyslexia read 27% faster on a small device with short lines, with no loss of understanding (Schneps and colleagues, PLoS ONE). So no study fixes one best length. A range of about 45 to 75 characters is a convention, backed by what readers prefer and by readers who need shorter lines.
CSS has a unit that sounds made for this. 1ch is the width of the digit zero in the element’s font (CSS Values 4). Suppose you write max-inline-size: 65ch on the article.
Pause and predict: with a width of 65ch, how many characters fit on one line of the article?
In one run in Chrome 157, with 65ch on the article, the line-counting code from the start of this module printed this:
87 85 86 70
About 86 characters, not 65. The specification says that ch is only an approximation, and exact only in a monospace font. Most letters and the space are narrower than a zero. This console code compares the two in Inter at 18 px:
const ctx = document.createElement("canvas").getContext("2d");
ctx.font = "18px Inter";
const sample = document.querySelector("article p:nth-of-type(2)").textContent;
const zero = ctx.measureText("0").width;
const average = ctx.measureText(sample).width / sample.length;
console.log("zero", zero.toFixed(2), "average", average.toFixed(2), "ratio", (average / zero).toFixed(3));
On the article page, it printed this:
zero 11.36 average 8.49 ratio 0.748
An average character in this paragraph is 0.748 of a zero. So 65ch holds about 65 / 0.748 = 87 characters, as the count showed.
So for about 65 characters, you need 65 × 0.748 = 48.6ch, and the lab rounds that to 50ch. But the ratio depends on the font. In one run of the same count at 16 px in Chrome on macOS, 65ch held about 80 characters of Arial and about 90 of Georgia.
max-inline-size is the logical form of max-width. In a horizontal language, it limits the width. Figure 5 shows max-inline-size: 50ch on the article.


Figure 5: no measure (top) and a measure of 50ch (bottom), at 1280 px. The first paragraph went from three lines of about 146 characters to six lines of about 64.
Run the line-counting code again, and it now prints 64 66 61 67 62 8. A ch measure follows the font. If the font changes, so does the measure, which is what you want, but check the count again.
The measure has costs. The page is longer, and the right half of a wide window is empty.
Where the column sits, and what fills the rest of the window, is layout, the topic of Module 7. Put the measure on the text column, not on a container that also holds wide images or tables. On narrow columns, hyphens: auto evens out the lines if the page has a lang attribute. It’s Baseline widely available since 2026-03-18.
Rule: Set the measure in
ch, then count the characters it really holds in your font. Aim for about 45 to 75.
Line height by size
Module 2 defined leading as the extra space a line gets above and below its letters, which CSS puts inside the line height. The site has no line-height rule, so every element uses normal. With Inter at 18 px, that gives lines 21 px apart, 1.17 times the font size.
Module 3 named the cost of Inter’s large x-height. The space between lines looks smaller, so the text needs more line height. The recommendations again differ:
- Google Fonts Knowledge: 115% to 150% for body text in Latin scripts, more for small text, and less on narrow phone columns (Choosing a suitable line height).
- Butterick: 120% to 145% of the font size (Practical Typography).
- MDN: at least 1.5 for the main text, citing WCAG (MDN, line-height).
WCAG 2.2 sets two levels. Success Criterion 1.4.12, Text Spacing (Level AA), doesn’t require 1.5. But it requires that nothing breaks when a reader sets line height to 1.5 and letter spacing to 0.12em with their own styles (Understanding 1.4.12).
So never put text in a box with a fixed height. Success Criterion 1.4.8 (Level AAA) asks for a way to get 1.5.
Dyson’s review found no recent studies of line spacing, and older results depended on other factors. So these ranges are conventions. Stashling uses 1.5, the top of Google’s range and MDN’s minimum, because Inter’s large x-height needs the room.
Write line height as a number with no unit. A number is inherited as a factor, so each element multiplies it by its own font size. But a length such as 1.1em is computed once and inherited as pixels. In MDN’s example, an h1 at 30 px sits inside a box with line-height: 1.1em at 15 px, so the heading gets 16.5 px lines, and they overlap.
The lab sets the line height on html:
html {
line-height: var(--leading-body);
}
Figure 6 shows the article on a phone before and after this rule.


Figure 6: line-height: normal (top) and 1.5 (bottom), at 390 px. The text gets room, and the title spreads apart.
The text is easier to follow, but the title now uses 1.5 too. At 28.2 px, its lines are 28.2 × 1.5 = 42.3 px apart, so the two lines read as two separate headings.
That’s because the gap you see grows with the font size. At 16 px, 1.5 adds 8 px of leading per line, but at 28 px it adds 14 px.
Large text also has shorter lines, so the eye has less distance to travel back. Google Fonts suggests a line height below the font size for very large titles, and about 1.1 to 1.2 is common for headings. So Stashling’s headings get 1.2, which puts the title’s lines 28.2 × 1.2 = 33.8 px apart:
h1,
h2,
h3 {
line-height: var(--leading-heading);
}
Figure 7 compares the title at both values.


Figure 7: a heading at 1.5 (top) and at 1.2 (bottom), at 390 px. Only the headings’ line height changed.
The rule is on html, not body, because of the rlh unit from Module 2, the line height of the root element. With the rule on html, 1rlh is 16 × 1.5 = 24 px. But body text at 1280 px is 18 px, so its own line is 27 px, and 1lh measures that one.
To space paragraphs by exactly one line of their own text, use 1lh. Both units are Baseline widely available since 2026-05-21. The lab keeps the browser’s paragraph margins.
Rule: Give body text a unitless line height around 1.5, and large headings less, about 1.1 to 1.2. The larger the text, the less extra space it needs.
Letter spacing for capitals and large headings
Tracking is extra space added evenly between all the letters of a piece of text. In CSS it’s letter-spacing (MDN). A type designer spaces each font for its normal use, so tracking changes what the designer drew.
Figure 8 shows two cases where tracking helps.

Figure 8: capitals at a small size get more tracking (A, B). A large heading gets a little less (C, D).
Capitals at text size look crowded (A). The usual explanation is that a font is spaced for small letters next to capitals. Two capitals side by side are wide shapes with no parts above or below to separate them.
Butterick recommends 5% to 12% extra for text in capitals, in CSS 0.05em to 0.12em (Practical Typography). We found no reading study on this, so treat it as a convention.
Large headings go the other way (C). The same spacing that looks right at 18 px looks loose at 44 px. So display sizes, the large sizes used for titles, often get a little negative tracking (Google Fonts Knowledge).
No source we read gives a number, so the lab uses -0.02em on h1, chosen by eye.
Write tracking in em, so it grows with the font size. Four limits apply:
- A value other than 0 turns off optional ligatures, such as “fi” drawn as one shape.
- Arabic and other connected scripts break apart with tracking. Don’t track them.
- Don’t tighten body text. Extra-large letter spacing helped children with dyslexia read in a 2012 study (Zorzi and colleagues, PNAS), and WCAG 1.4.12 asks that layouts survive a reader’s 0.12em.
letter-spacingisn’t applied at the start or end of a line (CSS Text 4).
Stashling has no text in capitals, so the lab adds no rule for them. If you set a label in capitals with text-transform: uppercase, add letter-spacing: 0.08em to it.
Rule: Add tracking to capitals at small sizes, and remove a little from large headings. Leave body text as the designer spaced it.
Weight carries hierarchy where size cannot
On a phone, the scale’s ratio is 1.2, so a feature heading on the landing page (h3, --step-1) is 19.2 px, and the text below it is 16 px.
Pause and predict: Figure 9 shows the feature cards at 390 px. In the top one, the headings have
font-weight: 400. Do they still read as headings?


Figure 9: feature headings at weight 400 (top) and 700 (bottom), at 390 px. On a phone, the size step alone is too small to mark a heading.
At weight 400, the headings look like a larger first line of the text. Weight changes how dark a line looks without making it longer, while size changes both. So where a narrow screen limits the size, weight carries the difference. That’s reasoning from Module 1’s hierarchy, not a study.
That’s why the lab keeps the browser’s bold (700) for headings. Inter’s variable file from Module 3 can draw any weight from 100 to 900, such as 600 for a quieter heading.
Two limits apply. MDN warns that weights of 100 and 200 are hard to read for people with low vision (MDN, font-weight). Bold on everything, as on Module 1’s landing page, makes nothing stand out.
Rule: Where the size step is small, as on a phone, use weight to separate headings from text. Keep thin weights out of text.
Balanced headings and fewer short last lines
Look at the article’s title and first paragraph in the top of Figure 10. The title breaks after “Piece”, so its first line is long and its second short. The paragraph ends with one word on its last line.
text-wrap: balance tells the browser to choose line breaks so that the lines of a block are about the same length (CSS Text 4). The specification leaves the method to the browser. Chromium balances blocks of up to six lines and Firefox up to ten (MDN, text-wrap-style). It changes where lines break, not the width of the box, so a balanced heading can leave space at its right side.
text-wrap: pretty asks the browser to prefer better breaks over speed. It may avoid a very short last line, even out the right edge of a paragraph and limit hyphens in a row. Browsers do this differently. The WebKit team writes that Chromium adjusts only the last four lines of a paragraph, while Safari considers the whole paragraph (WebKit blog, 2025).


Figure 10: normal wrapping (top) and text-wrap: balance on the title with pretty on the paragraph (bottom), at 1280 px in Chrome 157.
The lab adds balance to every heading and pretty to the article’s paragraphs. Their sources disagree on how widely to use pretty. The specification and MDN warn that it costs layout time, and suggest using it on longer text only.
But WebKit’s post says its cost doesn’t depend on how many elements use it, and suggests using it widely. Stashling uses it on the one block of long text.
Support differs too. text-wrap: balance is Baseline newly available since 2024-05-13, when Safari 17.5 added it. Thirty months later, on 2026-11-13, it could have become widely available. But the web-features data (3.46.0) and MDN still marked it newly available on 2026-11-18.
text-wrap: pretty works in Chrome 117 and Safari 26, but not in Firefox, so it’s limited. In a browser without them, the text wraps as before, which is the top of Figure 10.
Rule: Use
text-wrap: balanceon headings andprettyon long paragraphs. Both are safe to add, because browsers without them wrap as usual.
Choices and costs
| Decision | Choice | Cost or limit | Choose something else when |
|---|---|---|---|
| Sizes | A type scale | Only the sizes it gives; a ratio too large for phones or too small to see | One page needs a size the scale lacks: add a step, not a one-off |
| Sizes | Fixed sizes with breakpoints | Every size jumps at each breakpoint | You need exact sizes at a few known widths |
| Sizes | Fluid sizes with clamp() |
The vw part ignores the font size setting; a wide max-to-min ratio fails zoom |
The range is small enough that one fixed size works |
| Unit | rem |
1 rem changes with the reader’s setting, so layouts must flex | A size should follow its parent, such as an icon inside a button: use em |
| Measure | max-inline-size in ch |
The character count depends on the font; check it | Use em if you want the width independent of the zero’s shape |
| Line height | One body value, near 1.5 | Large text looks gappy with it | Headings and display text need less |
| Tracking | Positive on small capitals | Turns off optional ligatures | The script is connected, such as Arabic |
| Tracking | Negative on large headings | No source gives a number; too much makes letters touch | The text is body size |
| Line breaks | balance and pretty |
Results differ by browser; pretty costs layout time |
Very long pages where layout speed matters more |
What changed recently in CSS and standards
All Baseline statuses are from the web-features data (version 3.46.0) and MDN, read on 2026-11-18.
clamp(),min()andmax()became Baseline widely available on 2023-01-28.text-wrap: balancebecame Baseline newly available on 2024-05-13. Thetext-wrapshorthand followed on 2024-10-17.text-wrap: prettyis still limited: Chrome 117 (2023), Safari 26 (2025), no Firefox.- WCAG 2.2 is a W3C Recommendation, in its 12 December 2024 edition.
hyphensbecame Baseline widely available on 2026-03-18,lhandrlhon 2026-05-21, andpow()on 2026-06-07.- Chrome 146 added
<meta name="text-scale">, which only Chrome and Edge support. - The latest CSS Text Module Level 4 Working Draft, which defines
text-wrap-style, is dated 14 August 2026.
The other properties in the lab have worked in all major browsers for years: font-size, line-height, letter-spacing, font-weight, rem and ch since before 2018. max-inline-size is part of logical properties, Baseline widely available since 2024-03-20.
Online tools for this step
These tools compute a type scale or fluid sizes. None of them checks zoom, so run the zoom check above or zoom the page yourself.
- Utopia fluid type scale calculator. You enter a minimum and maximum viewport width, a base size and a ratio at each end, and the number of steps. It draws the scale and prints custom properties named
--step-0and up, asclamp()values, relative to the viewport or a container. It is free to use. Limit: the page doesn’t mention zoom or WCAG 1.4.4, so check the ratio of maximum to minimum yourself. The same site has spacing and grid calculators. - Fluid Type Scale Calculator. The same idea, with options for
remorpxoutput, container units, a media query fallback, step names and rounding, and a live preview in a font you choose. It is free. Limit: no zoom check. - Typescale. It previews a fixed scale in a font from a list, with line height and letter spacing, and generates CSS. The preset ratios from 1.067 to 1.618 are free. A custom ratio is marked as part of its Pro plan, and saving needs an account. Limit: its sizes aren’t fluid.
- DevTools. The Computed pane shows each element’s resolved
font-sizeandline-heightin px, so you can read aclamp()at the current width. Firefox’s Fonts panel lets you change size, line height and weight live. DevTools don’t show sizes under zoom. Browser zoom and the font size setting are the real test.
Check yourself
Critique: the documentation page that ignores its readers
A command-line tool’s documentation page uses Inter. Its CSS includes these rules:
/* excerpt */
html { font-size: 15px; }
h1 { font-size: 6vw; letter-spacing: 0.05em; line-height: 1.5; }
main { max-width: 900px; }
p { line-height: 1; letter-spacing: -0.03em; }
Readers send four complaints. Zooming in makes the text no larger, and neither does the browser’s font size setting. On a laptop, the paragraphs are hard to follow from line to line.
On a phone, the title is barely larger than the text, while on a large monitor it’s huge and its two lines look like two headings. The body text looks squeezed.
Hint 1
For the first complaint, ask which unit each size uses, and what zoom and the font size setting each change.
Hint 2
For the laptop, count characters: Module 3 measured an average Inter character at 16 px as 7.55 px wide. For the squeezed text, look at both properties in the p rule.
Answer
html { font-size: 15px } locks the root, so the font size setting can’t change rem. The title uses vw alone, which is failure F94: zoom makes the viewport narrower, so the title gets no larger. So delete the root rule and write every size in rem. Then make the title fluid with clamp() and a rem part, with a maximum at most 2.5 times its minimum.
The main element is 900 px wide. At 15 px, an average Inter character is about 7.55 × 15 / 16 = 7.08 px, so a line holds about 900 / 7.08 = 127 characters. So set a measure in ch on the text column, then count what it holds.
The paragraphs have line-height: 1, too little for a font with a large x-height, and negative tracking, which body text shouldn’t have. So use about 1.5 and remove the tracking.
The title has the opposite settings. It needs a lower line height, about 1.1 to 1.2, so its lines read as one heading. Its positive tracking belongs on small capitals; a large heading takes 0 or a little less.
Review questions
- With a ratio of 1.5 from 16 px, how large is step 4, and why is that a problem on a phone?
- Why does
font-size: clamp(1rem, 5vw, 4rem)fail the zoom check at 1280 px, and what would you change? - You write
max-inline-size: 65chfor text in Inter. About how many characters fit on a line, and why not 65? - Why is body text at line height 1.5 while the article’s title is at 1.2? And why do small capitals get more tracking while the title gets less?
- On a phone, the
h3is 19.2 px and the text is 16 px. What keeps the heading visible, and what does a browser withouttext-wrap: balanceshow?
Answers
- 81 px, five times the text size. On a 375 px screen, a line at that size holds very few letters, so phones need a smaller ratio.
- Its maximum is four times its minimum, and its middle is
vwalone, which doesn’t grow with zoom. So at 1280 px no zoom up to 500% makes it more than 1.25 times larger. Add arempart to the middle and keep the maximum within 2.5 times the minimum. - About 87.
1chis the width of the zero, and an average character in Inter is 0.748 of that. So for about 65 characters, use about 49ch. - The gap you see grows with the font size, and large text has shorter lines. At 28 px, 1.5 puts the title’s lines 42 px apart, so they read as two headings. A font is spaced for small letters at text size. So capitals side by side look crowded, and the same spacing looks loose at 44 px.
- Its weight. Bold makes it darker without making it longer. Without
balance, the browser wraps the heading as usual, so the result is the same as before the rule.
The lab: set the article’s type
In about 15 minutes, you’ll set the sizes, measure, line height, tracking and line breaks of the sample site. Start from the module-03 folder and keep article.html open. Reload after each step. The finished files are in the module-04 folder of the course repository.
Step 1: add the type scale and use it everywhere
Why: every font size comes from one scale that grows with the screen (see “Fluid sizes with clamp()“).
In tokens.css, replace the line --size-title: 40px; with these lines. They’re the script’s output, with the comments aligned:
/* Type scale: fluid from a 320px to a 1280px viewport,
ratio 1.2 from 16px, growing to ratio 1.25 from 18px. */
--step--1: clamp(0.8333rem, 0.8111rem + 0.1111vw, 0.9rem); /* 13.33 to 14.40px */
--step-0: clamp(1rem, 0.9583rem + 0.2083vw, 1.125rem); /* 16.00 to 18.00px */
--step-1: clamp(1.2rem, 1.1312rem + 0.3438vw, 1.4063rem); /* 19.20 to 22.50px */
--step-2: clamp(1.44rem, 1.3341rem + 0.5297vw, 1.7578rem); /* 23.04 to 28.13px */
--step-3: clamp(1.728rem, 1.5716rem + 0.7821vw, 2.1973rem); /* 27.65 to 35.16px */
--step-4: clamp(2.0736rem, 1.8493rem + 1.1216vw, 2.7466rem); /* 33.18 to 43.95px */
--size-title: var(--step-4); /* the one largest text on a page */
--size-title keeps its name, so .hero h1 in index.css needs no change. It now points to the top step, 33.18 to 43.95 px, in place of a fixed 40 px.
Then replace each font-size in px with a step. Change only the value; the rest of each rule stays:
| File | Rule | Old value | New value |
|---|---|---|---|
base.css |
body |
18px |
var(--step-0) |
base.css |
h1 |
24px |
var(--step-3) |
base.css |
h2 |
20px |
var(--step-2) |
base.css |
h3 |
18px |
var(--step-1) |
base.css |
.logo |
20px |
var(--step-1) |
base.css |
.button |
16px |
var(--step-0) |
base.css |
.site-footer |
14px |
var(--step--1) |
index.css |
.stats |
20px |
var(--step-1) |
settings.css |
.settings input, .settings select |
16px |
var(--step-0) |
settings.css |
.status |
14px |
var(--step--1) |
signup.css |
the input and select rule |
16px |
var(--step-0) |
What you should see: the bottom of Figure 4. At 1280 px, the title is 35 px and the headings 28 px. The text stays at 18 px.
Make the window narrow, and every size shrinks smoothly. To check that none is left, search the CSS files for font-size: followed by a number; there should be no match.
Step 2: limit the line length
Why: a line of 146 characters is about twice the recommended length (see “Line length: set a measure in ch“).
In tokens.css, add an empty line after --size-title, then this line:
--measure: 50ch; /* text column: about 65 characters of Inter */
In base.css, after the h3 rule, add this rule:
article {
max-inline-size: var(--measure);
}
What you should see: the bottom of Figure 5. The article is a column about 570 px wide at the left of the window. The landing page and the settings page don’t change, because they have no article.
Step 3: set the line heights
Why: Inter’s large x-height needs more space between lines of text, and large headings need less (see “Line height by size”).
In tokens.css, add these lines after --measure:
--leading-body: 1.5; /* line height of text */
--leading-heading: 1.2; /* line height of headings */
In base.css, add this rule before the body rule:
html {
line-height: var(--leading-body);
}
Then add this rule before the h1 rule:
h1,
h2,
h3 {
line-height: var(--leading-heading);
}
What you should see: the bottom of Figures 6 and 7. Every page gets taller. The header, the buttons and the table rows get taller too, because they inherit 1.5. The table rows go from 30 to 36 px at 1280 px.
Step 4: tighten the largest headings
Why: large headings look loose with the spacing made for text (see “Letter spacing for capitals and large headings”).
In tokens.css, add this line after --leading-heading:
--tracking-tight: -0.02em; /* large headings */
In base.css, add a line to the h1 rule, so it reads:
h1 {
font-size: var(--step-3);
letter-spacing: var(--tracking-tight);
}
What you should see: the article title and the landing page’s title are slightly narrower, as in line D of Figure 8. The difference is small, so compare by toggling the line in DevTools.
Step 5: balance the headings and the paragraphs
Why: even heading lines and fewer one-word last lines (see “Balanced headings and fewer short last lines”).
In base.css, add text-wrap: balance to the rule from step 3:
h1,
h2,
h3 {
line-height: var(--leading-heading);
text-wrap: balance;
}
Then add this rule after the article rule:
article p {
text-wrap: pretty;
}
What you should see: the bottom of Figure 10, in Chrome or Safari. In Firefox, the paragraph’s last line doesn’t change, because Firefox doesn’t support pretty.
Step 6: check the result
Why: a measure, a fluid size and a font size setting each need a check in a real browser.
- At 1280 px, run the line-counting code from the start of this module. It prints
64 66 61 67 57 13. At 390 px, it prints48 47 35 47 50 42 46 13. - Run
getComputedStyle(document.body).fontSize. At 1280 px it prints17.999px, not18px, because the script rounds each number to four decimals. - Zoom the page to 200% and then 250% with the browser’s zoom. The text must keep growing, and nothing may be cut off.
- Set the browser’s default font size to 20 px, and run the console line from “Sizes in
remfollow the reader’s settings” again. At 1280 px the body is 21.83 px. Set the font size back afterward.
Figure 11 shows the finished page at both widths.


Figure 11: the finished article at 1280 px (top) and 390 px (bottom), in the same crops as Figures 1 and 2.
What you should see: the page in Figure 11. The text still starts 10 px from the edge on a phone. That padding, and the empty space on a wide screen, are layout, which Module 7 covers.
Optional: apply it to a page of your own
Pick a text-heavy page you built, and answer four questions:
- Which font sizes does its CSS use? Search for
font-sizeand list them in order. Do the steps follow one ratio? - How many characters does a full line hold at your widest and narrowest width? Use the line-counting code, with your own selector.
- What line height does the body text have, and what do the headings inherit?
- Does the text reach twice its size at 200% or 250% zoom, and does it follow the browser’s font size setting?
Then build a scale with the script or one of the calculators, set a measure in ch, and run the checks from step 6.
Module 4 cheat sheet
Scale base size x ratio^step; 1.2 on phones, 1.25 on wide screens
Fluid clamp(min rem, start rem + slope vw, max rem); max <= 2.5 x min
Units font sizes in rem; never lock html's font-size
Measure max-inline-size in ch, then count: 50ch = about 65 in Inter
Leading unitless; text 1.5, headings 1.2; set on html for 1rlh
Tracking capitals at small sizes +0.05em to +0.12em; big headings -0.02em
Weight bold separates headings where the size step is small
Wrap text-wrap: balance on headings; pretty on long paragraphs
Check zoom to 200% and 250%; default font size at 20 px
Module 5, How Color Works on a Screen, starts with two status colors that have the same HSL lightness and look very different.
Sources
Reading research:
- M. C. Dyson, “How physical text layout affects reading from screen“, Behaviour & Information Technology 23(6), 2004. The place to start for going deeper on line length and line spacing.
- M. H. Schneps and colleagues, “Shorter lines facilitate reading in those who struggle“, PLoS ONE, 2013.
- M. Zorzi and colleagues, “Extra-large letter spacing improves reading in dyslexia“, PNAS, 2012.
Type references:
- Tim Brown, “More Meaningful Typography“, A List Apart, 2011, on modular scales.
- Matthew Butterick, Practical Typography, on line length, line spacing and letter spacing. A book, cited here for what it recommends.
- Google Fonts Knowledge: “Understanding measure“, “Choosing a suitable line height” and “Track carefully or not at all“.
- Maxwell Barvian, “Addressing Accessibility Concerns With Using Fluid Type“, Smashing Magazine, 2023, and Miriam Suzanne, “Baseline in action: fluid type“, web.dev, 2025.
Standards and browsers:
- W3C, WCAG 2.2, with Understanding 1.4.4 Resize Text, 1.4.8 Visual Presentation and 1.4.12 Text Spacing, and failure F94.
- W3C, CSS Values and Units Module Level 4, Working Draft, 12 March 2024:
clamp(),ch,lhandrlh. - W3C, CSS Text Module Level 4, Working Draft, 14 August 2026:
text-wrap-styleandletter-spacing. - MDN, “clamp()“, “length“, “line-height“, “letter-spacing“, “font-weight” and “text-wrap-style“.
- Jen Simmons, “Better typography with text-wrap pretty“, WebKit blog, 2025, and Chrome for Developers, “Respect the OS text scale“.