Sub topic 2
Start with type size
Leading and line length both depend on type size. Before you adjust either, settle the size of the text. This chapter assumes you know what a font size is, can read basic CSS, and have seen px, rem, and em units.
Why size comes first
Leading is usually written as a ratio of the font size, such as 1.5. Line length is measured in characters, and the width of a character grows with the font size. If you change the size after tuning the other two, both values drift. A line that held 65 characters at 16px holds about 52 at 20px in the same column.
So the order is:
- Choose the type size.
- Choose the measure for that size.
- Choose the leading for that size and measure.
What "type size" means
Type size is the nominal height of the type, set in CSS with font-size. It is not the height of any single letter. It is the size of the em box, the invisible square the designer drew each glyph inside. Two typefaces set at the same font-size can look quite different in size.
The visible difference comes from the x-height. This is the height of lowercase letters such as x, a, and e, measured without ascenders (the tall parts of b, d, h) or descenders (the tails of g, p, y). Body text is mostly lowercase, so x-height controls how large the text looks.
| Typeface | Relative x-height | Looks at 16px |
|---|---|---|
| Typeface with a large x-height | Tall | Larger than its size suggests |
| Typeface with a small x-height | Short | Smaller than its size suggests |
When you switch typefaces, you may need to change the size to get the same apparent size. Do this before you touch leading or measure.
Choosing a body size for screens
Most browsers default to a body size of 16px. This default is a good starting point for body text on screens. Many designers go a little larger, and values from 16px to 20px are common for long reading.
Several factors push the number up or down:
- Reading distance. Phones are held closer than desktop monitors, but phone screens are small. Desktop text is read from farther away and often needs a larger size.
- Typeface. A small x-height needs a larger size.
- Audience. Older readers and readers with low vision benefit from larger text.
- Content. Long articles justify a larger, more comfortable size. Footnotes, captions, and legal text can be smaller, but they should stay legible.
The following sections give the numbers for each, but the size you pick here is the input.
Use relative units
Set the size in rem or em, not in px. A rem is relative to the root element's font size, which is the browser default of 16px unless the user changed it. Setting size in rem respects the reader's own browser setting. If a reader sets a larger default, your text grows with it. Setting font-size: 16px on the body overrides that choice.
html {
/* Leave this alone so the user's browser setting still applies. */
font-size: 100%;
}
body {
font-size: 1rem; /* 16px at the browser default */
}
.caption {
font-size: 0.875rem; /* 14px at the browser default */
}Here 100% means "use the browser default". It is the safe way to say you are not overriding the reader's preference. Everything else is then a multiple of that base.
`rem` and `em` compared
| Unit | Relative to | Typical use |
|---|---|---|
| `rem` | The root element's font size | Body text, headings, spacing that should not compound |
| `em` | The font size of the current element (or its parent, for `font-size` itself) | Spacing that should scale with the local text size |
em compounds when you nest it. A 1.2em list inside a 1.2em list is 1.44 times the base. This surprises people. For font-size, prefer rem.
How size changes the other two values
The size you choose changes what "comfortable" means for both measure and leading. The next chapters give specific ranges. Here is the effect in outline.
Size and measure. Measure is counted in characters per line. A wider glyph takes more horizontal space, so a larger size fits fewer characters in the same column width. When you increase the type size, either widen the column to keep the character count, or accept a shorter line. This is why the CSS later in this tutorial uses the ch unit. A ch is roughly the width of the digit "0" in the element's font and size, so a width in ch follows the size automatically.
Size and leading. If leading is written as a unitless ratio, such as 1.5, then the line spacing scales with the size. A 16px font at 1.5 has 24px lines. A 20px font at 1.5 has 30px lines. The ratio holds while the absolute gap grows. If you instead write leading in fixed units, such as line-height: 24px, a larger font will have too little space between lines, and the lines may touch.
/* Fragile: the line height does not follow the font size. */
.bad {
font-size: 1.25rem;
line-height: 24px;
}
/* Better: the line height follows the font size. */
.good {
font-size: 1.25rem;
line-height: 1.5;
}Because .bad has a 20px font in a 24px line, only 4px is left for the gap between lines, which is cramped for body text. Because .good has a 20px font and a 30px line, it keeps the same proportions as the 16px version.
Size and the type scale
Body text is rarely the only text on a page. Headings, captions, and notes need sizes too. A type scale is a short list of sizes related by a fixed ratio, so that the sizes look planned rather than random. For example, with a base of 1rem and a ratio of 1.25, the steps are 1rem, 1.25rem, 1.5625rem, and so on.
You do not need a full scale to set up a readable paragraph. You do need to fix the body size first, because the rest of the scale is built from it. Changing the body size later changes everything that was derived from it.
Common mistakes
- Choosing leading before size. A line height of 1.5 on the wrong size still gives you the wrong paragraph.
- Judging size on one typeface. A size that looks right in one typeface may look small in another with a lower x-height.
- Setting
font-sizeinpxonhtmlorbody. This ignores the reader's browser setting. - Using fixed-unit line heights. These break when the size changes, including when a reader zooms or raises their default size.
- Testing only on your own screen. Check the size on a phone and on a large monitor, because the right size depends on the device and viewing distance.
Practical routine
- Pick a typeface.
- Set
font-size: 1remonbodyand leavehtmlat100%. - Look at a paragraph of real text, not placeholder text. Compare lowercase letters against the surrounding page.
- If the text looks small, increase the size in small steps, for example to
1.125rem. - Fix the size. Only then move on to measure and leading.
Exercise
A paragraph uses font-size: 1.25rem and line-height: 24px. A reader raises their browser default size from 16px to 20px. What happens to the line spacing, and how would you change the CSS so the spacing follows the text?
Show answer
The font grows to 1.25 × 20px = 25px, but the line height stays at 24px, so the lines are shorter than the text is tall and they overlap or touch. Replace the fixed value with a unitless ratio, such as line-height: 1.5, so the line height is 1.5 × the font size (37.5px here) and scales with the text.
Exercise
Why should you choose the type size before the measure and leading?
Show answer
Both depend on the size. Measure is counted in characters, and a larger size fits fewer characters into the same width. Leading is a ratio of the font size, so it is only meaningful once the size is known. Changing the size afterward would shift both values.