Sub topic 4
Building a Type Scale from a Base Size and Ratio
This chapter assumes you know basic type vocabulary (typeface, font size, weight) and can read simple CSS. You will build a type scale, a fixed set of font sizes that every heading level and the body text draw from.
Why a scale beats picking sizes by eye
Choosing sizes one at a time tends to produce levels that are almost, but not quite, different. A subhead at 22px beside a headline at 24px looks like a mistake instead of a ranking. A type scale fixes this by generating every size from two inputs: a base size and a ratio.
- The base size is the body text size, usually 1rem (16px in most browsers). Body text is the baseline because readers spend most of their time in it.
- The ratio is the number each step is multiplied by to get the next step.
Because each step is a constant multiple of the one before, the jump between levels looks consistent across the whole page.
Computing the steps
With a base of 1rem and a ratio of 1.25 (called a major third), each step is the previous step times 1.25.
| Step | Calculation | Size (rem) | Size (px at 16px) |
|---|---|---|---|
| 0 | 1 | 1 | 16 |
| 1 | 1 × 1.25 | 1.25 | 20 |
| 2 | 1.25 × 1.25 | 1.563 | 25 |
| 3 | 1.563 × 1.25 | 1.953 | 31 |
| 4 | 1.953 × 1.25 | 2.441 | 39 |
You can also compute step n directly as base × ratio^n. For step 4: 1 × 1.25⁴ = 2.441.
Writing the scale in CSS
Store each step as a custom property (a CSS variable) on :root, then assign steps to elements.
: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); }This example skips --step-3. Skipping a step is a valid choice. It makes the headline stand out more from the subheads than the neighboring levels do from each other. Keeping unused steps defined costs nothing and leaves room for a pull quote or a lead paragraph later.
Choosing a ratio
The ratio controls how dramatic the hierarchy feels.
| Ratio | Name | Typical use |
|---|---|---|
| 1.125 | Major second | Dense interfaces, small screens |
| 1.25 | Major third | General articles and websites |
| 1.333 | Perfect fourth | Editorial pages with clear contrast |
| 1.5 | Perfect fifth | Posters, landing pages, bold headlines |
A small ratio produces levels that sit close together, so you may need more weight or spacing to separate them. A large ratio separates levels clearly, but the top steps grow quickly and can overwhelm narrow screens.
Common errors
- Levels too close. If two adjacent levels differ by less than about 10 to 15 percent, readers see them as the same. Raise the ratio or skip a step.
- Too many sizes. Using values outside the scale, such as 1.4rem for one caption, weakens the system. Add a step or reuse an existing one.
- Pixel sizes everywhere. Sizes in
remfollow the reader's browser font setting, while fixedpxvalues do not. - Scale as the only cue. Size is one signal. Weight, spacing, and color work with it, and later chapters cover them.
Exercise
Your base size is 1rem and your ratio is 1.333. What are steps 1, 2, and 3, rounded to three decimal places? Would you use step 1 for a subhead if the body text is step 0?
Show answer
Step 1 is 1 × 1.333 = 1.333rem. Step 2 is 1.333 × 1.333 = 1.777rem. Step 3 is 1.777 × 1.333 = 2.369rem. Step 1 is a reasonable subhead size here, because it is a third larger than the body text, which is a clear and visible difference.
Exercise
A page uses 16px body text, 18px subheads, and a 22px headline. What is the problem, and how would you fix it with a scale?
Show answer
The subhead is only 12.5 percent larger than the body text, so the levels look almost the same. Pick a ratio such as 1.25 and use its steps (16px, 20px, 25px, 31px, 39px), assigning body to step 0, subheads to step 2 or step 1, and the headline to a higher step.