Sub topic 3
Body text: choosing the baseline
This chapter assumes you know the basic vocabulary of type (typeface, font size, weight, italic). It also assumes you can read simple HTML and CSS. The code examples use CSS, but the reasoning applies equally in a design tool.
Why body text comes first
Most pages are mostly body text. Headlines and subheads are rare, so they work as signals against a background of paragraphs. That background has to be decided first. Every other level in the hierarchy is measured against it.
A headline is "large" only relative to body text. A subhead is "emphasized" only because it differs from the paragraph below it. If you set the headline first and fit the body text around it, you tend to end up with body text that is too small, too tight, or too wide. If you set the body text first, the other levels become a series of choices about how far each should differ from it.
Body text has three jobs:
- It carries the detail of the message.
- It is the part readers spend the most time with.
- It sets the unit (size, spacing, line length) that the rest of the layout is built from.
Choosing the size
Browsers default to a body size of 16 pixels, which is 1rem. This is a good starting point for screens, and it is the one the example scale in this tutorial uses. A rem is a unit equal to the root element's font size. Because it follows the root size, it also follows the reader's own browser setting.
Some practical rules:
- For long reading on screens, stay between about 16 and 20 pixels (1rem to 1.25rem). Go toward the high end for a serif with a small x-height or for readers who sit far from the screen.
- For print, 9 to 12 points is typical, depending on the typeface and the paper.
- Use
remfor font sizes so the reader's preference scales your layout. Settinghtml { font-size: 62.5%; }as a shortcut is a common mistake, because it shrinks everything for readers who chose a larger default. - Do not drop body text below 14 pixels to make a design "feel refined." Small text trades the reader's effort for your aesthetics.
The x-height is the height of lowercase letters such as "x", measured from the baseline. Two typefaces at the same nominal size can look quite different in size, because the one with a taller x-height looks bigger. When you compare typefaces, compare them at a size that looks equal, then check the nominal size.
Choosing a typeface for body text
The body face needs to be readable in long stretches. The qualities that matter most are:
- A moderate x-height, so lowercase letters are clear without looking oversized.
- Open letter shapes, where the gaps in letters such as "a", "c", and "e" are not too narrow.
- Clear differences between similar characters, such as capital "I", lowercase "l", and the digit "1".
- Even spacing, so words form clean shapes.
- A regular weight (400) that is not too thin, as thin strokes fade on low-resolution screens.
Both serif and sans-serif faces work. Choose by the quality of the specific face and the context, not by a rule that one category is always more readable. Pairing a body face with a different heading face is covered in a later chapter. For now, pick one good body face and use it consistently.
Always list fallbacks, so a missing font does not push the layout into an unplanned default:
body {
font-family: Georgia, "Times New Roman", serif;
font-size: 1rem;
line-height: 1.5;
}Setting line height and line length together
Size is only one of three settings that define the body baseline. The other two are line height and line length. Later chapters cover them in detail, so this section covers only the starting values.
- Line height (also called leading) is the distance from one baseline to the next. A unitless value such as
1.5multiplies the element's own font size, so it adjusts when the size changes. A value with a unit, such as24px, is inherited as a fixed number, which can cause cramped text in nested elements with larger type. - Line length (also called measure) is how wide a line of text runs. Around 45 to 75 characters per line is a common comfortable range. The
chunit is roughly the width of the digit "0" in the current font, so65chis a convenient way to target about 65 characters.
body {
font-family: Georgia, serif;
font-size: 1rem;
line-height: 1.5;
}
p {
max-width: 65ch;
}
h1 {
font-size: 2.441rem;
line-height: 1.15;
font-weight: 700;
}The headline here uses tighter leading than the body. The reason is that a headline is large and short. Large type with generous leading leaves visible gaps between lines. The body keeps its looser leading because it runs for many lines.
Weight and color in body text
Keep body text at regular weight. Weight is a signal in a hierarchy, so using bold or light across whole paragraphs removes the signal from the places where you need it. Reserve bold for short phrases and for headings. Use italic for titles, foreign words, or light emphasis, and avoid long italic passages, which are harder to read.
Color matters too, but with limits. Dark text on a light background should have enough contrast to meet WCAG, the Web Content Accessibility Guidelines. For normal-size text, WCAG level AA requires a contrast ratio of at least 4.5:1. Pure black on pure white is allowed, but many designers use a very dark gray such as #222 on white to reduce glare. That pairing still passes by a wide margin.
Avoid mid-gray body text. A light gray such as #999 on white gives a ratio of about 2.8:1, which fails AA. The failure is easy to miss on a bright monitor and obvious in sunlight.
The role of semantic markup
Body text should be marked up as paragraphs, and headings as heading elements. The markup records the hierarchy independent of the visual style, so assistive technology can navigate it:
<article>
<h1>Headline states the main idea</h1>
<p class="lead">A short intro sentence in slightly larger text.</p>
<h2>Subhead introduces a section</h2>
<p>Body text carries the detail.</p>
</article>Do not style a <p> to look like a heading, or a <div> to look like a paragraph. Screen reader users who jump between headings will miss the fake ones.
Common errors
| Error | Effect | Fix |
|---|---|---|
| Body text below 14px | Readers squint or zoom | Start at `1rem` |
| Fixed `px` size on `html` | Ignores the reader's browser setting | Use `rem` and leave `html` alone |
| `line-height: 1` on paragraphs | Lines crowd, and the eye slips to the wrong line | Use about `1.5` |
| No `max-width` on paragraphs | Lines run across a wide screen, so readers lose their place at line ends | Use `max-width: 65ch` |
| Light weight or light gray | Fails contrast and fades on low-resolution screens | Regular weight, contrast of 4.5:1 or more |
| Different body sizes across pages | Each page feels like a different site | Define the size once and reuse it |
Edge cases
- Tables and captions. These often use smaller text than the body. Keep them at least 0.875rem and make the step down deliberate, not accidental.
- Narrow columns. In a sidebar, 65ch may not fit. Let the column's width set the measure, and check that lines do not drop below about 30 characters, where ragged breaks multiply.
- Dark backgrounds. Light text on dark can look bolder than the reverse, an effect called irradiation. You may want slightly more leading and a slightly lighter weight, while still checking contrast.
- Languages with long words or different scripts. Some languages need more leading or wider measure than English. Test with real content, not placeholder text.
- Text zoom. Readers can enlarge text to 200%. Fixed-height containers will clip it. Let containers grow with their content.
A quick check for your baseline
Before you design the headings, print or load a page of real paragraphs and ask:
- Can you read it comfortably at arm's length?
- Can you tell where each line ends and the next begins without effort?
- Do you ever lose your place when moving from the end of one line to the start of the next?
- Does the text pass a contrast checker?
If any answer is no, change the body settings before moving on. Fixing the baseline later forces every other level to change with it.
Exercise
A page sets html { font-size: 12px; }, paragraphs in #999 on a white background, and line-height: 1 with no max-width on paragraphs. List the changes you would make to the body text baseline and why.
Show answer
Remove the fixed 12px on html so the root follows the reader's browser setting, and set body text to font-size: 1rem (16px by default), since 12px is too small for long reading. Change the color to a dark value such as #222, because #999 on white is about 2.8:1 and fails the WCAG AA minimum of 4.5:1. Set line-height: 1.5 so lines do not crowd and the eye can find the next line. Add max-width: 65ch to paragraphs so lines stay in the comfortable range of about 45 to 75 characters instead of stretching across the screen.
Exercise
Why is a unitless line-height: 1.5 safer than line-height: 24px on the body element?
Show answer
A unitless value is a multiplier that each element applies to its own font size, so larger or smaller text inside the body gets proportional spacing. A value with a unit is computed once and inherited as a fixed length, so a larger element inside the body could end up with lines that are too tight.