Sub topic 5
Headlines: the entry point
This chapter assumes you know the basic vocabulary of type (typeface, size, weight, italic) and can read simple CSS and HTML. It also assumes you have seen the type scale from the earlier chapter, where each level steps up from a 1rem body size by a ratio of 1.25.
What a headline does
A headline is the first thing most readers notice on a page. It has two jobs. It states the main idea, so a reader who stops there still learns something. It also invites the reader into the body text below it.
A headline can only do this if it is clearly the top level. Size contrast does most of the work. Weight and spacing support it.
Pick a size from the scale
Take the headline size from your type scale, not from guesswork. In the scale from the earlier chapter, --step-4 is 2.441rem, which is about 2.4 times the body size. That gap is large enough that no one will confuse the two levels.
Skipping steps is deliberate here. The h1 in the scale uses --step-4, while h2 uses --step-2 and h3 uses --step-1. The headline stands apart from the subheads, and the subheads stay close to each other.
Tighten the leading
Body text needs generous line height, around 1.5, because readers move across many long lines. A headline is large and usually runs one to three lines. At 1.5, the gaps between those lines look loose and the lines drift apart into separate pieces.
Reduce the line height as the size grows:
body {
font-family: Georgia, serif;
font-size: 1rem;
line-height: 1.5;
}
h1 {
font-size: 2.441rem;
line-height: 1.15;
font-weight: 700;
}A unitless value such as 1.15 multiplies the element's own font size. It stays correct if the size changes later.
Use semantic markup
Write the headline as an h1, not as a styled p. The element tells the browser and assistive technology that this is the top-level heading. Screen reader users often move through a page by headings, so the structure has to be in the markup.
<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>Use one h1 per page. Choose each heading level for its place in the outline, not for how large it looks. If a level looks wrong, change its CSS.
Keep the headline from overwhelming small screens
A 2.441rem headline can wrap into five or six lines on a narrow phone. The clamp() function sets a minimum, a preferred fluid value, and a maximum:
h1 {
font-size: clamp(1.75rem, 1.2rem + 2.5vw, 2.75rem);
}The headline then shrinks on small screens and stops growing on wide ones, while the body stays at 1rem.
Common errors
| Error | Result | Fix |
|---|---|---|
| Headline only slightly larger than the subheads | Levels blur together | Use a step from the scale with clear contrast |
| Body line height on a large headline | Lines look disconnected | Use about 1.1 to 1.2 |
| Bold, italic, capitals, and color all at once | Noise replaces emphasis | Pick one or two cues |
| Using `h1` for a visual effect | Broken outline for screen readers | Match the level to the structure |
Exercise
Exercise
A page has a 1rem body with line-height 1.5. Its h1 is 2.441rem, also with line-height 1.5. The headline wraps to three lines and looks loose. What change would you make, and why is a unitless value a good choice?
Show answer
Set the h1 line-height to about 1.15. Large text needs less relative spacing because its lines are few and the size already creates separation. A unitless value multiplies the element's own font size, so it stays proportional if the size or the clamp() result changes.
Exercise
Why should the headline be an h1 element instead of a p styled to look large?
Show answer
The h1 element states the page's top-level heading in the markup. Browsers and screen readers use that structure to navigate, and CSS can style it without losing meaning. A styled p looks right but carries no structure.