Sub topic 7
Set a type scale and heading rhythm
This chapter covers the typography step: choosing a type scale, setting line heights and spacing, and making headings read as a clear sequence. It assumes you have a low-fidelity wireframe with ranked sections, that you can use a design tool such as Figma, and that you can read basic CSS. The wireframe from the previous chapter gives you the content order. Typography now gives that order a visible shape.
Why typography comes before color
In a wireframe, hierarchy comes from position and box size. In a mockup, most of it comes from type. A visitor scans headings first, so the size, weight, and spacing of text decide whether the ranking you built is visible.
Typography also feeds later steps. The sizes you pick become design tokens, and they are checked in the accessibility pass. Settling them now avoids rework.
The working model
A type system for a homepage has four parts:
- Typeface: the font family. Use one family for most pages, or two at most (one for headings, one for body text).
- Type scale: a fixed set of sizes. Every piece of text uses a size from the set and nothing else.
- Line height and measure: the vertical space between lines and the width of a text line.
- Rhythm: the repeated spacing between headings, paragraphs, and sections.
The scale is the core idea. Without it, designers pick sizes by eye, and the page ends up with 17px here and 19px there. A scale limits the choices so the page looks consistent.
Build a type scale
A type scale is a list of sizes, each related to the one before it. There are two common ways to build one.
- Ratio-based (modular) scale. Pick a base size and multiply it by a fixed ratio for each step up. A ratio of 1.25 (called a major third) gives gentle steps. A ratio of 1.5 gives dramatic ones.
- Hand-picked scale. Choose a short list of sizes that suit your content and round them to clean values.
For a homepage with a 16px base, a 1.25 ratio gives these sizes:
| Step | Calculation | Size | Typical use |
|---|---|---|---|
| Body | 16 | 16px (1rem) | Paragraphs, navigation |
| Large | 16 × 1.25 | 20px | Hero supporting text |
| H3 | 16 × 1.25² | 25px | Card titles |
| H2 | 16 × 1.25³ | 31px | Section headings |
| H1 | 16 × 1.25⁴ | 39px | Hero headline |
Ratio math often gives odd numbers like 24.4px. Round them. The spine's example CSS uses 1rem for body text, 1.75rem for H2, and 2.5rem for H1. These are hand-picked values, and that is fine. What matters is that the set is small and every size has a job.
Choose the ratio for the page
A homepage hero needs more contrast between sizes than a documentation page does. A tight ratio (1.125 to 1.2) suits dense interfaces. A wider ratio (1.25 to 1.333) suits marketing pages, where the H1 must stand out from body text at a glance.
A common edge case is that the top of the scale grows too large on small screens. A 2.5rem headline that looks right on desktop can wrap to five lines on a phone. The responsive chapter returns to this. For now, define the desktop sizes and note that the H1 will need a smaller mobile value.
Set line height and measure
Size alone does not make text readable. Two other values matter.
- Line height is the distance from one baseline to the next. Body text reads well at 1.5 times the font size. Headings need less, usually 1.1 to 1.3, because large text with loose lines looks disconnected.
- Measure is the length of a line of text. Aim for roughly 45 to 75 characters. Lines much longer than that make the eye lose its place on the return to the next line.
Use unitless line heights in CSS. A unitless value is multiplied by each element's own font size, so a heading and a paragraph both scale correctly. A fixed value such as 24px is inherited as 24px by children, which can squash larger text inside them.
Build the heading rhythm
Rhythm is the pattern of space around text. A good rhythm tells the reader which text belongs together.
The key rule is that a heading belongs to the content below it. So the space above a heading should be larger than the space below it. If the gaps are equal, the heading floats between two blocks and the reader cannot tell which one it introduces.
A workable pattern, using the spacing scale from the grid chapter:
- Space between sections:
--space-4(2.5rem) or more. - Space above a heading inside a section:
--space-3. - Space between a heading and its first paragraph:
--space-1. - Space between paragraphs:
--space-2.
Taking all spacing values from one scale is what creates rhythm. The eye picks up the repeated gaps even when it cannot name them.
Keep the heading levels in order
Visual size and heading level are separate things. The level (h1, h2, h3) describes document structure, which screen readers and search engines use. Size describes appearance.
- Use exactly one
h1per page, normally the hero headline. - Do not skip levels. An
h3should sit under anh2. - Do not pick a level because of the size you want. Pick the level for the structure, then style it to the size you need.
Put it into CSS
The following stylesheet implements the scale, line heights, measure, and heading rhythm. It extends the custom properties from the spine, so the values match the tokens a developer will later receive.
:root {
--space-1: 0.5rem;
--space-2: 1rem;
--space-3: 1.5rem;
--space-4: 2.5rem;
--font-size-body: 1rem;
--font-size-h3: 1.25rem;
--font-size-h2: 1.75rem;
--font-size-h1: 2.5rem;
--line-height-body: 1.5;
--line-height-heading: 1.2;
}
body {
font-family: system-ui, sans-serif;
font-size: var(--font-size-body);
line-height: var(--line-height-body);
}
h1, h2, h3 {
line-height: var(--line-height-heading);
margin: var(--space-3) 0 var(--space-1);
}
h1 { font-size: var(--font-size-h1); }
h2 { font-size: var(--font-size-h2); }
h3 { font-size: var(--font-size-h3); }
p {
margin: 0 0 var(--space-2);
max-width: 65ch;
}Three details are worth noting. Each heading has a larger top margin than bottom margin, which ties it to the text below. The max-width: 65ch caps the measure, where ch is roughly the width of the zero character in the current font. And sizes use rem, so they follow the visitor's browser font setting instead of overriding it.
Common errors
- Too many sizes. If the file has more than six or seven text sizes, the scale is not being followed. Merge near-duplicates.
- Weight and size doing the same job. Making a heading both huge and extra bold is often redundant. Pick one main signal and use the other lightly.
- Equal spacing above and below headings. This breaks the grouping described above.
- Pixel font sizes in code. Pixels ignore the visitor's default text size. Use
rem. - Text over images with no check. Typography choices must still pass the contrast checks later. Note any text placed on imagery now.
- Choosing level by looks. Skipping from
h1toh4becauseh4is smaller creates a broken outline. - Too many font files. Each weight and style of a typeface is a separate download. Limit yourself to two or three weights, and prefer a system font stack if load speed matters more than brand character.
In the design tool
Create text styles for each step of the scale and name them by role, for example Heading/H1, Heading/H2, Body/Regular. Name by role, not by size, so changing a size later does not leave a style called "Heading 40" holding 44px. Apply styles instead of setting sizes by hand. This is the groundwork for the design tokens chapter, where these styles map directly to the CSS variables above.
Where this fits
Typography is one of three visual decisions, alongside the layout grid and color. All three feed the high-fidelity mockup and the tokens. Your type scale does not need to be perfect now. It needs to be consistent, because consistent systems are easy to adjust later.
Exercise
A section on your homepage has an h2 heading followed by a paragraph. The heading has 1.5rem of margin above and 1.5rem below, and the reader says the heading looks detached from its paragraph. What change fixes it, and why?
Show answer
Reduce the space below the heading, for example to 0.5rem (--space-1), and keep or increase the space above. A heading should be closer to the content it introduces than to the content before it. Equal gaps make the heading float between two blocks, so unequal gaps restore the grouping.
Exercise
Your design has an h1 at 2.5rem, and a designer wants an h4 for a card title because "h4 is smaller and looks right". The card sits directly under an h2. What should you do?
Show answer
Use an h3 for the card title and style it to the size you want with CSS or a text style. Heading levels describe structure and must not skip levels, so the card title under an h2 should be an h3 regardless of how large or small it looks.
Exercise
A paragraph in your CSS has line-height: 24px, and a span inside it has font-size: 2rem. Why is that a problem, and what is the better value?
Show answer
A fixed line height is inherited as 24px, so the larger text inside the span gets lines that are too tight and may overlap. Use a unitless value such as 1.5, which each element multiplies by its own font size.