Sub topic 5
Body text: size, line height, and line length
Body text is the text people actually read on a page. Headings help them find their place, but paragraphs carry the content. This chapter covers the three settings that most affect how readable a paragraph is: font size, line height, and line length. It also covers the errors that tend to appear when these are set carelessly.
Prerequisites
This chapter assumes you know the following:
- Basic HTML elements, including
p,h1toh3, andfigure. - CSS selectors and the properties
font-size,font-weight, andcolor. - The type scale and custom properties from the earlier chapters. This chapter reuses
--text-baseand--leading-body.
What makes body text different
Body text is the default text style of a page. Every other role (heading, caption, label) is defined by how it differs from it. If the body style is wrong, the rest of the hierarchy has nothing stable to compare against.
Body text also has a different job from headings. A reader scans a heading in a glance. A reader moves through a paragraph line by line, often for minutes. Settings that look fine on a three-word heading can tire the eye over three hundred words.
Three properties control most of this:
| Property | What it controls | Typical value for body text |
|---|---|---|
| `font-size` | How large each character is | `1rem` (usually 16px) |
| `line-height` | Vertical distance between baselines of consecutive lines | `1.5` |
| `max-width` in `ch` | How many characters fit on one line | `65ch` |
Font size
Start from the browser default
Browsers set the root font size to 16px unless the user changes it. Setting body { font-size: 1rem; } keeps that default. This respects people who have raised their default size in browser settings because they find small text hard to read.
Avoid setting the size on html or body in px. A pixel value overrides the user's preference. A percentage or rem value keeps it.
/* Respects the user's browser setting */
body {
font-size: 1rem;
}
/* Ignores it: avoid */
body {
font-size: 16px;
}How small is too small
For long reading, 16px is a sensible floor on most screens. Going down to 14px can be acceptable for dense interfaces, and secondary text such as captions often uses 0.875rem. Going below that for body text makes reading harder, especially on phones held at normal distance.
Larger text is not always better either. Body text at 24px on a wide desktop screen forces the eye to travel farther per word and breaks lines into fewer words, which feels choppy. The goal is a comfortable size relative to the reader's device and distance.
Use relative units for everything text-related
rem is relative to the root font size. em is relative to the font size of the current element. Both scale when the user changes their default. Use rem for font sizes so values do not compound.
A common error is nesting em values:
li {
font-size: 0.9em;
}With this rule, a list nested inside a list item shrinks again, because each li is 0.9 times its parent. Three levels deep, the text is about 73% of the original size. Using 0.9rem avoids the compounding.
Line height
Line height is the distance from one baseline to the next. In CSS, line-height sets this distance. Too little and the descenders of one line touch the ascenders of the next. Too much and the lines fall apart into separate strips, so the eye loses its place when it returns to the left edge.
Use a unitless number
Write line-height: 1.5, not line-height: 150% or line-height: 1.5rem. A unitless number is a multiplier that each element applies to its own font size. A percentage or length is calculated once on the parent and inherited as a fixed value.
The difference shows up as soon as a child has a different font size:
<article class="percent">
<p>Body text inherits a computed line height.</p>
<small>Small text inherits the same fixed value.</small>
</article>
<article class="unitless">
<p>Body text uses 1.5 times its own size.</p>
<small>Small text uses 1.5 times its own, smaller size.</small>
</article>.percent { font-size: 1rem; line-height: 150%; }
.unitless { font-size: 1rem; line-height: 1.5; }In .percent, the small element inherits a computed 24px line height even though its text is smaller, so its lines sit too far apart. In .unitless, the small element recalculates from its own size and stays proportionate.
Choose a value by role
Line height depends on the role of the text. Body text needs room. Headings are short and large, so they need less.
:root {
--leading-body: 1.5;
--leading-heading: 1.2;
}
body {
line-height: var(--leading-body);
}
h1, h2, h3 {
line-height: var(--leading-heading);
}Values between 1.4 and 1.6 suit most body text. Accessibility guidance (WCAG 1.4.12, Text Spacing) expects that content still works when a user overrides line height to at least 1.5 times the font size. That means your layout should not break if line height increases. Avoid fixed-height containers that clip text when it grows.
Spacing between paragraphs
Line height controls space inside a paragraph. Space between paragraphs is a separate decision. Use margin, and make it clearly larger than the gap between lines so the reader can see where one paragraph ends.
p {
margin-block: 0 1em;
}A margin of one line (1em with a 1.5 line height gives roughly two-thirds of a line) is a common choice. Do not simulate paragraph spacing with empty <p> elements or <br> tags. Those add meaningless elements that screen readers may announce.
Line length
Line length, also called measure, is the number of characters on a line. It is the setting most often forgotten, because a browser will happily stretch a paragraph across a 2000px monitor.
If lines are too long, the eye has trouble finding the start of the next line. If they are too short, the reader's eye jumps back too often and the text reads in fragments. A range of about 45 to 75 characters per line is widely recommended for body text, and 65 is a common target.
Set it with `ch`
The ch unit is the width of the "0" character in the current font. It is a close proxy for an average character, so max-width: 65ch gives roughly 65 characters per line regardless of font size.
p {
max-width: 65ch;
}Use max-width, not width. With max-width, the paragraph still shrinks on a narrow screen. A fixed width: 65ch would cause horizontal scrolling on a phone narrower than that.
Limit the container or the paragraph
You have two options. Limiting each p works but leaves lists, quotes, and other text blocks unconstrained. Limiting a container is often cleaner.
.prose {
max-width: 65ch;
margin-inline: auto;
}<main class="prose">
<h1>Trail Guide</h1>
<p>A short introduction to planning a multi-day hike.</p>
<ul>
<li>Footwear</li>
<li>Layers</li>
<li>Food</li>
</ul>
</main>The container approach keeps headings, paragraphs, and lists aligned on the same column. The trade-off is that full-width elements such as large images must either live inside the column or break out of it deliberately.
Edge cases
- Multi-column layouts. In a narrow sidebar or a CSS grid column, the column itself limits line length. Do not add a second
max-widththat conflicts with it. - Languages with different character widths. For Chinese, Japanese, and Korean text, a limit of around 40 characters per line is often cited, because each character is wider than a Latin letter. Check recommendations for the language you support.
- Centered text. Long centered paragraphs are hard to read because the left edge changes on every line. Reserve centering for short text such as a tagline.
- Justified text.
text-align: justifycan create uneven word gaps on narrow columns. Left-aligned text (for left-to-right languages) is the safer default for web body text.
Putting the three together
The following stylesheet gives a page a complete body text treatment, using the tokens from earlier chapters.
:root {
--text-base: 1rem;
--leading-body: 1.5;
}
body {
font-family: system-ui, sans-serif;
font-size: var(--text-base);
line-height: var(--leading-body);
color: #1a1a1a;
background: #ffffff;
}
p {
max-width: 65ch;
margin-block: 0 1em;
}The relationship between the settings can be summarized as a decision flow.
Common errors
| Symptom | Likely cause | Fix |
|---|---|---|
| Text does not grow when the user raises the browser font size | Sizes set in `px` | Use `rem` |
| Small text inside a container has oversized gaps between lines | `line-height` set as a percentage or length on the parent | Use a unitless number |
| Nested lists keep shrinking | Compounding `em` font sizes | Use `rem` |
| A paragraph runs the full width of a wide monitor | No line length limit | Add `max-width: 65ch` |
| Horizontal scrollbar on phones | Fixed `width` in `ch` or `px` | Use `max-width` |
| Text clipped when users increase spacing | Fixed `height` on the container | Use `min-height` or let content size the box |
| Paragraph gaps look the same as line gaps | No paragraph margin | Add margin below each paragraph |
Testing your settings
Check these on a real page rather than assuming they work:
- Increase the browser's default font size and confirm that body text grows with it.
- Zoom the page to 200% and confirm that no text is clipped and no horizontal scrolling is needed for ordinary text.
- Resize the window from phone width to a wide monitor. Count characters on a line at both extremes. Lines should stay close to the 45 to 75 range wherever the layout allows.
- Apply a user stylesheet or browser extension that sets line height to 1.5 and paragraph spacing larger. Confirm that nothing overlaps.
Summary of decisions
- Set body size in
rem, starting at1rem. - Use a unitless line height near 1.5 for body text and a smaller one near 1.2 for headings.
- Limit line length with
max-widthinch, aiming for about 65 characters. - Separate paragraphs with margin, not empty elements.
- Test with enlarged fonts, zoom, and user-adjusted spacing.
Exercise
A page uses body { font-size: 16px; line-height: 150%; }. A <small> element inside a paragraph has font-size: 0.75rem. The paragraph text is wider than 100 characters per line on a desktop monitor. Name three changes that would improve readability and say why each helps.
Show answer
1) Change font-size: 16px to 1rem so the text respects the user's browser font-size setting. 2) Change line-height: 150% to 1.5 so each element, including the small element, calculates its line height from its own font size instead of inheriting a fixed computed value from the parent. 3) Add max-width: 65ch to paragraphs or to a containing element so lines stay within roughly 45 to 75 characters, which makes it easier for the eye to find the start of the next line.
Exercise
You set p { width: 65ch; } and users on small phones report a horizontal scrollbar. What is wrong, and what is the fix?
Show answer
A fixed width of 65ch is wider than a narrow phone screen, so the page overflows horizontally. Use max-width: 65ch instead. The paragraph then takes the full available width on a small screen and stops growing at about 65 characters on a large one.