3 / 6 · Intermediate
Colour contrast
Light grey #999999 on white has a contrast ratio of 2.85:1, well under the 4.5:1 that WCAG 2.2 asks for body text.
Jump to the 10 practice questionsYou will learn
- Read a contrast ratio and compare it with the WCAG thresholds
- Pick text colours that pass AA and AAA
Before this: Heading structure and landmarks
1Explore
Measured, not guessed
Text that is pale against its background is hard to read for people with low vision, for many older readers and for anyone using a phone in sunlight. WCAG 2.2 does not leave "pale" to taste. It measures the relative luminance of the two colours, a number from 0 for black to 1 for white. It then compares them with the contrast ratio (L1 + 0.05) / (L2 + 0.05), where L1 is the lighter colour. The result runs from 1:1, a colour on itself, to 21:1, black on white.
Each choice shows the colour on white and its contrast ratio, computed with the WCAG formula.
Tap a choice: the code and the preview change together.
<p style="font-size: 18px"><span style="color: #999999">Closed on public holidays.</span> <b>#999999 2.85:1</b></p>Nothing is drawn: there is no visible content.
2Problem
Black on white
What is the contrast ratio of #000000 on #ffffff?
:1
Hint
(1 + 0.05) / (0 + 0.05).
Solution
Answer: 21 :1
(1 + 0.05) / (0 + 0.05) = 21.
3Explain
The thresholds
Success criterion 1.4.3 Contrast (Minimum), at level AA, asks for at least 4.5:1 for normal text and 3:1 for large text, which WCAG defines as at least 18 point, or 14 point bold. Criterion 1.4.6 at level AAA raises these to 7:1 and 4.5:1. Criterion 1.4.11 Non-text Contrast asks for 3:1 for the parts of controls and graphics that people need to see, such as the border of a text field or the lines of a chart. Logos and text that is purely decorative or part of an inactive control are exempt.
Five text colours on white with their contrast ratios, computed with the WCAG 2.2 formula. #999999 fails, #767676 just passes AA, #595959 passes AAA.
4Problem
Normal text, AA
What contrast ratio does WCAG 1.4.3 require for normal body text?
:1
Hint
The lower number is only for large text.
Solution
Answer: 4.5 :1
Normal text needs at least 4.5:1 at level AA. The lower threshold for large text cannot be applied merely because the designer prefers a paler colour.
5Problem
Large text, AA
And for large text at level AA?
:1
Hint
18 point, or 14 point bold.
Solution
Answer: 3 :1
Large text (18 pt, or 14 pt bold) needs 3:1.
6Problem
Normal text, AAA
What is the minimum AAA ratio for normal text?
:1
Hint
Criterion 1.4.6.
Solution
Answer: 7 :1
Criterion 1.4.6 raises normal text to 7:1 for AAA. The 4.5:1 minimum belongs to AA and is not enough for that higher target.
7Explain
Values worth remembering
A few values are worth remembering. The grey #767676 gives 4.54:1 on white, and is often quoted as the lightest plain grey that passes AA; #777777 gives 4.48:1 and fails. The darker #595959 reaches 7.00:1 and passes AAA. Saturated colours can be misleading: pure red #ff0000 on white is only 4.00:1, while the deeper red #c01c28 reaches 6.11:1. Placeholder text inside form fields is a frequent failure, because designers often make it very light on purpose.
8Problem
The lightest passing grey
Which grey just passes AA on white?
Hint
4.48 is below 4.5.
Solution
Answer: #767676 (4.54:1)
The grey with 4.54:1 reaches the 4.5:1 threshold. The 4.48:1 grey falls below it, even though the two colours look very similar.
9Problem
#999999 for body text
Grey #999999 on white is 2.85:1. For body text it
Hint
2.85 is below 3.
Solution
Answer: fails AA
2.85 is below 4.5, and even below 3 for large text.
10Problem
Pure red
Pure red #ff0000 on white: contrast ratio to two decimals?
:1
Hint
The relative luminance of red is 0.2126.
Solution
Answer: 4 :1
L of red = 0.2126; 1.05 / 0.2626 = 4.00.
11Explain
Colour must not be the only cue
Contrast between text and background is half the story. Criterion 1.4.1 Use of Color, at level A, says colour must not be the only way information is shown. Red #c01c28 and blue #1a5fb4 both read well on white, but against each other their ratio is only 1.03:1. In greyscale, or to someone who cannot tell red from blue, they become the same grey. So a required field marked only by a red label, or a link that differs from the text around it only by colour, needs a second cue: a word, an icon, an underline.
Red #c01c28 and blue #1a5fb4 have almost the same luminance, so in greyscale they look nearly identical.
12Problem
Red against blue
Red #c01c28 and blue #1a5fb4 against each other are 1.03:1. What does that mean?
Hint
1.03:1 is almost no difference in brightness.
Solution
Answer: They look almost the same in greyscale
Equal luminance means the only difference is hue, which some people cannot see.
13Problem
A link shown only by colour
A link is shown only by being blue. Which fix meets 1.4.1?
Hint
Add a cue that does not depend on colour.
Solution
Answer: Add an underline
A second cue that does not depend on colour, such as an underline.
14Problem
The border of a text field
Which criterion asks for 3:1 for the border of a text field?
Hint
Controls and meaningful graphics.
Solution
Answer: 1.4.11 Non-text Contrast
1.4.11 covers controls and meaningful graphics.
15Practice
Make the note pass AAA
The note text is #999999, which gives 2.85:1 on white. Change its colour to #595959 so it passes AAA at 7.00:1.
- note colour #595959
<style>
body { background: #ffffff; }
.note { color: #999999; }
</style>
<h1>Opening hours</h1>
<p class="note">Closed on public holidays.</p>Hint
#595959 reaches 7.00:1.
A solution
<style>
body { background: #ffffff; }
.note { color: #595959; }
</style>
<h1>Opening hours</h1>
<p class="note">Closed on public holidays.</p>16Practice
Bring back the underline
The link differs from the text around it only by colour. Bring back the underline with text-decoration: underline.
- link underlined
<style>
a { color: #1a5fb4; text-decoration: none; }
</style>
<p>Our sourdough uses a <a href="/starter">ten-year-old starter</a> and slow proving.</p>Hint
A darker blue is still only colour.
A solution
<style>
a { color: #1a5fb4; text-decoration: underline; }
</style>
<p>Our sourdough uses a <a href="/starter">ten-year-old starter</a> and slow proving.</p>17Practice
Required in words
The email field is marked as required only by a red label. Add the word (required) inside the label so the cue is not colour alone.
- label says required
<style>
.req { color: #c01c28; }
</style>
<form>
<label class="req" for="email">Email</label>
<input id="email" type="email">
</form>Hint
Put the word inside the label.
A solution
<style>
.req { color: #c01c28; }
</style>
<form>
<label class="req" for="email">Email (required)</label>
<input id="email" type="email">
</form>18Explain
Common mistakes
<style>
input::placeholder { color: #c8c8c8; }
</style>
<input placeholder="you@example.com"><style>
input::placeholder { color: #757575; }
</style>
<label for="e">Email</label>
<input id="e" placeholder="you@example.com">Pale placeholder text fails contrast and disappears when you type. Darken it and give the field a real label.
19
Summary
- Contrast ratio = (L1 + 0.05) / (L2 + 0.05), from 1:1 to 21:1.
- AA: 4.5:1 normal text, 3:1 large text (1.4.3); 3:1 for controls and graphics (1.4.11).
- #767676 on white is 4.54:1; #999999 is 2.85:1.
- Colour must never be the only cue (1.4.1).