Sub topic 15
Testing and Refining a Hierarchy
This chapter assumes you know the basic vocabulary of type (typeface, size, weight, italic). It also assumes you have read the earlier chapters on type scales, line height, spacing, color contrast, and responsive type. Here you check whether those choices work together in a real layout.
Why test a hierarchy
A hierarchy can look right when you build it and still fail the reader. You know what the page says, so you can't easily see it as a stranger would. Testing gives you a way to step outside your own knowledge and find levels that blur together or compete.
The aim is simple. A new reader should be able to tell what the page is about, what its sections are, and where to start reading, within a few seconds.
The squint test
Lean back from the screen and squint until the text blurs. You can no longer read words, so you only see shapes, size, weight, and contrast. Then ask:
- Which element stands out first? It should be the headline.
- Does the eye move next to the subheads, and then to the body text?
- Do any elements compete, such as a bold subhead as loud as the headline?
- Do subheads look attached to the paragraph below them?
If two levels look the same when blurred, they are too close. Increase the size step, the weight difference, or the space around the heading.
The scan test
Ignore the body text and read only the headline and subheads, in order. They should work as an outline of the page. If you can't tell what the article covers, the headings are too vague, or the visual levels are too hard to pick out.
Also check that skipped levels are intentional. In HTML, going from an h1 straight to an h4 breaks the outline for screen reader users, who navigate by headings.
Check the numbers
Visual tests catch most problems. Numbers catch the rest. This audit script reads the computed styles of the headings and body text in a browser page and prints the size ratio between each level and the body.
const selectors = ["h1", "h2", "h3", "p"];
const body = parseFloat(getComputedStyle(document.querySelector("p")).fontSize);
for (const selector of selectors) {
const el = document.querySelector(selector);
if (!el) continue;
const style = getComputedStyle(el);
const size = parseFloat(style.fontSize);
console.log(
selector,
"size:", size + "px",
"ratio to body:", (size / body).toFixed(2),
"weight:", style.fontWeight,
"line-height:", style.lineHeight
);
}Run it in the browser console. With the 1.25 scale from earlier chapters, h2 should be near 1.56 times the body size and h1 near 2.44. If two adjacent levels show ratios below about 1.2 and the same weight, they are likely to blur together.
Test under real conditions
A hierarchy that works with sample text can break with real content. Try these cases:
- A headline that wraps to three lines.
- A subhead followed directly by another subhead.
- Very short and very long paragraphs.
- Narrow phone widths and wide desktop widths.
- Text zoomed to 200%.
- Contrast checked against the WCAG guideline of 4.5:1 for body text.
Refine in a fixed order
When a test shows a problem, adjust the strongest cues first, then fine-tune:
- Size step between levels.
- Spacing above and below headings.
- Weight and style.
- Color and contrast.
Stop when the levels read clearly. Adding more cues than needed makes a page noisy.
Common errors
- Judging only on your own large monitor.
- Testing with placeholder text that is shorter than real content.
- Fixing a weak hierarchy by making everything bold.
- Treating the ratio as a rule when the page still looks wrong.
Exercise
During a squint test, your h2 subheads and your body text look identical. Name two changes you could try, in the order the refine list suggests.
Show answer
First increase the size step between the h2 and body text, for example to the 1.563rem step from the scale. Then adjust spacing, such as a larger margin above the h2. If it still blurs, raise the weight, for example to 600.