Pick up a medicine box at home. The name of the medicine is printed large on the front. The directions are an ordinary paragraph. The warning is printed inside a box with a line around it: "Do not take on an empty stomach." Even someone who only glances at the box notices the name and the warning.
That box uses three text roles that every web page has too. The title names the page: what this page is. On the box, the title is the medicine's name. Body text is the text people read at length, like the directions for the medicine. A callout is a block set apart from the reading flow to say "don't miss this one", like the warning in its box.
The Terrace Room detail page
This is the Mist Homestay room detail page, with its three text roles. The HTML uses three tags (marks for each kind of content): <h1> for the page's main title, <p> for a paragraph, and <div> for a box with no special meaning. The CSS selects each element by its class: .title selects class="title". The CSS is inside the <style> tag.
<h1 class="title">Terrace Room</h1>
<p class="body">A first-floor room with a wooden terrace facing the potato garden. In the morning the mist comes down to the fence, so bring a jacket. Hot water runs all day and a fried rice breakfast is served at seven.</p>
<div class="callout">Free cancellation up to 3 days before check-in. For a 12 Dec check-in, that means 9 Dec at the latest.</div>
<style>
body { font-family: system-ui, sans-serif; color: #1f2937; }
.title { font-size: 1.875rem; font-weight: 700; line-height: 1.2; margin: 0 0 0.5rem; }
.body { font-size: 1rem; line-height: 1.6; max-width: 65ch; color: #374151; margin: 0 0 16px; }
.callout {
padding: 1rem 1.5rem;
border-left: 4px solid #3B82F6;
background-color: #EFF6FF;
color: #374151;
border-radius: 0 8px 8px 0;
}
</style>
Why does the cancellation rule get the callout? Because 8 of the 40 guest chats to Mrs. Sri asked "Can I cancel?". A question that people ask often deserves a place where nobody can miss it.
Title: large, bold and close to its content
font-size: 1.875rem= 30px.font-sizesets the size of the letters. 30 ÷ 16 = 1.875, so this title is 1.875 times the 16px body text. To be clearly a different level, a title should be at least about 1.5 times the body text.font-weight: 700, bold. The browser already makesh1700, but when you write it yourself, your intent is clear in the code.margin: 0 0 0.5rem:marginis the space outside an element, between it and its neighbours. Here that is 0.5rem (8px) at the bottom and 0 on the other sides. So the space above the title comes from whatever sits above it. As long as that space is more than 8px, the title sits closer to the paragraph under it, so the eye reads the title and that paragraph as one group.line-height: 1.2: tight lines, because the title is large.- Keep it short, ideally one line: "Terrace Room", not "Complete Information About Our Terrace Room".
Body text: 16px, relaxed lines, limited width
font-size: 1rem(16px), a comfortable size for body text.line-height: 1.6: every line is 16 × 1.6 = 25.6px tall.color: #374151: dark grey, not pure black. Its contrast on white is still 10.31:1, far above the WCAG minimum of 4.5:1.max-width: 65ch:max-widthis the largest width allowed. Thechunit equals the width of the digit 0 in that font, so this paragraph is at most 65 times as wide as a 0.
Why limit the width? Lines that are too long make the eye lose the start of the next line. Robert Bringhurst, in his book The Elements of Typographic Style, calls 45 to 75 characters per line a comfortable length, with 66 as the ideal. So the upper limit is about 65 to 75 characters, and the property (a named rule in CSS) that sets it is max-width. The value max-width: 65ch is close to Bringhurst's ideal of 66. In most fonts the digit 0 is wider than the average letter, so 65ch usually fits a little more than 65 characters. In the Lab, the longest line is counted directly from the text on the screen.
Callouts: calculated, not guessed
Suppose the 4px blue line on the left of the cancellation callout is removed. That line comes from border-left. Is the light blue background, from background-color (the background colour), still enough to make the callout visible? Contrast is calculated with the WCAG formula from the text hierarchy lesson:
| Pair | Contrast | What it means |
|---|---|---|
Text #374151 on background #EFF6FF |
9.47:1 | The callout text is easy to read, the 4.5:1 minimum is met |
Background #EFF6FF on the white page |
1.09:1 | Almost the same as white |
Line #3B82F6 on the white page |
3.68:1 | Clearly visible, above 3:1 |
Line #3B82F6 on background #EFF6FF |
3.38:1 | Still visible inside the callout |
The answer: not clearly any more. The light blue background is only 1.09:1 against white, and on a dim phone screen it can almost disappear. What really marks the callout is the 4px line, at 3.68:1 against the page. WCAG asks for at least 3:1 for graphical parts, like this line, that are needed to understand the content (criterion 1.4.11).
The spacing is calculated too. padding is the space inside a box, between its content and its edges. padding: 1rem 1.5rem means 16px at the top and bottom, 24px on the left and right. The callout text starts 4 + 24 = 28px from its outer left edge: the 4px line plus 24px of padding.
Why blue, not green? On Mrs. Sri's page, green #15803d already means "you can press this", because it is the colour of the book button. A green callout could be mistaken for a button. Light blue is used for information.
When to use a callout
- For things that change the reader's decision: the cancellation rule, a warning, a condition. Not to decorate an ordinary paragraph.
- Sparingly, one per section. If every paragraph becomes a callout, nothing stands out any more.
- Keep it short and concrete: "9 Dec at the latest" is more useful than "the cancellation deadline applies".
- Mark it for screen readers too. A screen reader is a program that reads the page aloud for blind users. The line and the blue background are visible only to the eye. The browser builds an accessibility tree, the structure of the page that screen readers read. In the accessibility tree of Chromium (the base of Chrome and Edge),
<div class="callout">is plain text, so a screen reader reads it like any other paragraph (WCAG 1.3.1). Start the content with a visible label, for example<strong>Important:</strong>(the word Important in bold), and addrole="note", so that the block appears asnotein the accessibility tree. Use<aside>for a side note outside the main flow, androle="alert"only for an error that has just appeared.
⚠️ Lines that run too long, callouts nobody sees
- Body text with no width limit. On a laptop screen, one line can be longer than 120 characters. Set
max-width: 65ch. - A callout made of background colour alone. A pale background like
#EFF6FFis only 1.09:1 against white. Add a line or border (an edge line) with at least 3:1 contrast. - Forgetting padding. Without
padding, the callout text sticks to its left line and to the edge of the background. - Everything becomes a callout. If three of the four blocks on a page are coloured, readers stop noticing them.
TL;DR: The title names the page. It is large (1.875rem = 30px, at least about 1.5 times the body text), weight 700, short, and close to its content (a gap of 0.5rem = 8px to the paragraph under it). Body text, the text read at length, is 1rem with line-height: 1.6 (the height of each line) and colour #374151 (contrast 10.31:1). Its width is limited with max-width: 65ch (a largest width of 65 times the width of the "0" character), because a comfortable line is 45 to 75 characters, with an upper limit of about 65 to 75. A callout is a block that highlights what must not be missed. The cancellation callout on Mrs. Sri's page uses padding: 1rem 1.5rem (the space inside the box), border-left: 4px solid #3B82F6 (a blue line on the left) and background-color: #EFF6FF (a light blue background). The pale background's contrast against white is only 1.09:1, so the line (3.68:1) is what marks the callout. The text starts 28px from the edge (4px of line plus 24px of padding).
⚡ Three text roles
Write:
<h1 class="title">Terrace Room</h1>
<p class="body">A first-floor room with a wooden terrace facing the potato garden.</p>
<div class="callout">Free cancellation up to 3 days before check-in. For a 12 Dec check-in, that means 9 Dec at the latest.</div>
Meaning: This is a room detail page of Mist Homestay. The title (in <h1>) names the page. Body text (in <p>) is the text read at length. A callout (in <div>) is a block set apart from the reading flow to say "don't miss this one". The cancellation rule gets a callout because 8 of 40 guest chats to Mrs. Sri asked about it.
⚡ Limit the paragraph's width
Write:
.body { font-size: 1rem; line-height: 1.6; max-width: 65ch; color: #374151; }
Guess first: at most about how many characters should one line of body text hold, and which property (CSS rule) limits it?
About 65 to 75 characters, through max-width (the largest width allowed). 65ch means 65 times the width of the "0" character.
Meaning: .body is the paragraph's class from the step before. Lines that are too long make the eye lose the start of the next line. A comfortable line is 45 to 75 characters.
⚡ The line is what marks a callout
Write:
.callout {
padding: 1rem 1.5rem;
border-left: 4px solid #3B82F6;
background-color: #EFF6FF;
}
Guess first: the 4px blue line (border-left) is removed. Is the light blue background still enough to mark the callout?
No, not clearly any more. The contrast ratio of the #EFF6FF background against white is only 1.09:1. The #3B82F6 line is 3.68:1, above the 3:1 minimum that WCAG asks for lines like this one.
Meaning: padding: 1rem 1.5rem is the space inside the box: 16px at the top and bottom, 24px on the left and right. So the text starts 28px from the left edge: the 4px line plus 24px of padding. Use callouts sparingly, for things that change the reader's decision.