Sub topic 4
Building a type scale from a base size and ratio
This chapter assumes you know the basic vocabulary of type (typeface, font size, weight, italic). It also assumes you can read simple CSS, including custom properties such as --step-0 and the rem unit. By the end you will be able to generate a set of heading sizes from one body size and one ratio. You will also be able to explain why that set stays distinct, and to spot the usual mistakes.
What a type scale is
A type scale is a short, fixed list of font sizes. Every piece of text in a layout takes its size from that list. It is not a set of sizes picked one at a time by eye.
You build it from two numbers:
- Base size: the size of body text. This is the baseline the whole hierarchy hangs from. On the web it is usually
1rem, which is 16px unless the reader has changed their browser setting. - Ratio: the number you multiply by to move from one step to the next.
Step 0 is the base size. Step 1 is the base times the ratio. Step 2 is step 1 times the ratio, and so on. Going down, you divide instead of multiplying.
This is why a scale beats ad hoc sizing. Size contrast is the strongest cue in a hierarchy, and it only works when the levels are clearly different from each other. Sizes picked by eye drift: 22px for one heading, 24px for another, 26px for a third. These sit close enough that the reader cannot tell the levels apart, yet they look unplanned. A constant ratio gives every level the same proportional jump over the one below it.
The calculation
With a ratio of 1.25 and a base of 1rem:
| Step | Calculation | Size in rem | Size at 16px |
|---|---|---|---|
| -1 | 1 / 1.25 | 0.8 | 12.8px |
| 0 | base | 1 | 16px |
| 1 | 1 x 1.25 | 1.25 | 20px |
| 2 | 1.25 x 1.25 | 1.563 | 25px |
| 3 | 1.563 x 1.25 | 1.953 | 31.25px |
| 4 | 1.953 x 1.25 | 2.441 | 39.06px |
| 5 | 2.441 x 1.25 | 3.052 | 48.83px |
The sizes grow geometrically, not by a fixed amount. Each step is 25 percent larger than the one before. The absolute gap between steps therefore widens as sizes grow: 4px between steps 0 and 1, but about 9.8px between steps 4 and 5. That matches how we see. A 4px difference is obvious on small text and invisible on a large headline, so large levels need larger gaps.
Writing the scale in CSS
Custom properties let you store the scale once and use it everywhere:
:root {
--step-0: 1rem;
--step-1: 1.25rem;
--step-2: 1.563rem;
--step-3: 1.953rem;
--step-4: 2.441rem;
}
body { font-size: var(--step-0); }
h3 { font-size: var(--step-1); }
h2 { font-size: var(--step-2); }
h1 { font-size: var(--step-4); }Three things are worth noticing.
- The values are rounded to three decimals. Browsers handle fractional
remvalues well, and more precision gains nothing visible. - The sizes are in
rem, notpx. Aremis relative to the root font size, so a reader who raises their default text size gets a scaled hierarchy with the ratios intact. - The headline uses
--step-4and skips--step-3. A scale is a menu, not a requirement to use every item. Here the headline jumps two steps above the subhead, which makes the top of the hierarchy more dramatic. Unused steps are available for a lead paragraph, a pull quote, or a later redesign.
Computing the steps instead of typing them
If you would rather change the ratio in one place, let CSS do the multiplication:
:root {
--ratio: 1.25;
--step-0: 1rem;
--step-1: calc(var(--step-0) * var(--ratio));
--step-2: calc(var(--step-1) * var(--ratio));
--step-3: calc(var(--step-2) * var(--ratio));
--step-4: calc(var(--step-3) * var(--ratio));
}
h1 { font-size: var(--step-4); }
h2 { font-size: var(--step-2); }
h3 { font-size: var(--step-1); }
body { font-size: var(--step-0); }Changing --ratio to 1.333 now rescales every level at once. This makes comparing ratios on a real page quick. The cost is that the final pixel values are less visible when you read the stylesheet, so keep a table like the one above in your design notes.
Choosing a ratio
Ratios come from music theory, where they name intervals. The names are only labels. What matters is how much contrast each one produces.
| Ratio | Common name | Typical use |
|---|---|---|
| 1.125 | Major second | Dense interfaces, dashboards, data tables |
| 1.2 | Minor third | Documentation, apps with many levels |
| 1.25 | Major third | General articles, blogs, marketing pages |
| 1.333 | Perfect fourth | Editorial layouts with strong headlines |
| 1.5 | Perfect fifth | Posters, landing-page heroes, few levels |
| 1.618 | Golden ratio | Very dramatic display type |
Two forces pull against each other.
- A small ratio gives gentle steps. You can fit many levels in a small range, but neighbouring levels may look too similar. Then size stops being the cue, and weight or spacing must carry the hierarchy.
- A large ratio gives clear steps, but sizes climb fast. With 1.5, step 5 is about 7.6 times the base. A fifth-level heading at that size will not fit on a phone.
A practical rule: count how many distinct levels the layout needs, then pick the smallest ratio that keeps adjacent levels clearly different. For a typical article (headline, subhead, body, caption) that is often 1.25 or 1.333.
Where each level lands
Body text sets the baseline, and the scale hangs from it. Choose the body size first, for readability. Roughly 16px to 20px suits most screen reading. Let the headlines follow from it. Doing it the other way round, picking a big headline and shrinking everything below, tends to produce body text that is too small.
A typical mapping for a 1.25 scale:
- Body text: step 0.
- Captions, footnotes, metadata: step -1.
- Third-level subheads: step 1.
- Second-level subheads: step 2.
- Page headline: step 3 or 4, depending on how much emphasis the page needs.
Common errors
- Too many sizes. A page that uses seven sizes from the scale, plus two that were typed by hand, has no hierarchy. Most layouts need four to six sizes. If you reach for a size that is not in the scale, change the scale or reconsider the element.
- Steps that are too close. With a ratio of 1.125, step 1 and step 2 are about 2px apart at body size. If you see this, use a larger ratio or skip steps, for example
h3at step 1 andh2at step 3. - Pixel sizes in some places,
remin others. This breaks the proportions when readers change their text size. Useremthroughout. - Expecting size alone to do the work. A scale controls size contrast only. Headings also need appropriate weight, line height, and spacing, covered in later chapters. A 1.563rem subhead set in the same weight and spacing as body text can still look like a loose sentence.
- Applying large steps unchanged on small screens. A 2.441rem headline is fine on a desktop but may break into awkward lines on a phone. The responsive typography chapter shows how to scale the steps with the viewport.
- Rounding too early. If you round each step to a whole pixel before multiplying, errors compound. Compute from the exact base and round only the final value.
Summary of the working model
- Fix the body size first, in
rem. - Pick the smallest ratio that keeps adjacent levels clearly different.
- Generate steps by multiplying up and dividing down.
- Store the steps as custom properties and use only those.
- Assign steps to roles, and leave some unused.
Exercise
A layout uses a 1rem body size and a ratio of 1.333. Calculate step 3 to three decimals. Then say whether this ratio or 1.2 would suit a phone layout with five heading levels, and why.
Show answer
Step 1 = 1.333, step 2 = 1.333 x 1.333 = 1.777, step 3 = 1.777 x 1.333 = 2.369rem (about 37.9px at 16px). For a phone layout with five levels, 1.2 suits better. Its step 5 is about 2.49 times the base, so the largest heading stays within a narrow screen. With 1.333, step 5 is about 4.2 times the base, which is likely to wrap awkwardly or overflow. The trade-off is that 1.2 gives smaller gaps between levels, so weight and spacing must help separate them.
Exercise
A stylesheet sets h1 to 2.4rem, h2 to 1.6rem, h3 to 1.3rem, and body text to 1rem. List two problems with this set from a type-scale point of view, and propose a fix using a 1.25 scale.
Show answer
First, the sizes follow no consistent ratio: h1 to h2 is 1.5, h2 to h3 is about 1.23, and h3 to body is 1.3, so the steps look arbitrary and h2 and h3 are close together. Second, these values are not stored as shared steps, so they invite more one-off sizes later. Fix: define steps 0 to 4 (1, 1.25, 1.563, 1.953, 2.441rem) as custom properties and assign body to step 0, h3 to step 1, h2 to step 2, and h1 to step 4 (or step 3 for a quieter page).