Skip to content

VIS-001 Give text at least 4.5:1 contrast against the colour it is actually drawn on

Level
Rule
Verdict
Requirement
Status
proposed, version 1.0.1

Rule

Text people need to read reaches 4.5:1 against the colour it is drawn on, or 3:1 when it is large. Measure after opacity, tints, overlays and images have done their work, in every state. Text in an inactive control, decoration and logos are exempt; see Exceptions.

Examples

Live examples built with Justified's components. Try them with the mouse, the keyboard or a screen reader.

Do: Secondary text keeps its colour

Light theme

Episodes

  • The lighthouse keeper's call
  • Night buses of Lisbon
  • A pharmacy at 3 a.m.
  • Publish date on the page: measuring …

Dark theme

Episodes

  • The lighthouse keeper's call
  • Night buses of Lisbon
  • A pharmacy at 3 a.m.
  • Publish date on the page: measuring …
The publish dates use text-muted-foreground as it is, in the light and in the dark theme. The figures under each scene are measured in your browser from what is painted. To make a date weigh less, make it smaller, not fainter.

Don't: Fading the date with opacity

Light theme

  • Publish date on the page: measuring …

Dark theme

  • Publish date on the page: measuring …
A drawing of the same list. Choose how the date is faded and read the figure under each theme: every choice fails on the light page, and the dark theme does not always save it (here some choices pass there), which is why the rule measures both. The drawing is not real text, so the page itself stays readable.

Do: A scrim under a title on a photo

Marrowfield Hours

Stories from people who work at night

  • Title against the lightest spot of the photo under the scrim: measuring …
The title sits on a bg-black/60 scrim. The figure is measured against the lightest spot of the photo behind the letters, not the average, and it still passes.

Don't: White title, no scrim, one spot checked

  • White title against the darkest part of the photo: measuring …
  • White title against the lightest part, behind the letters: measuring …
A drawing of the same cover with no scrim. Checked against the darkest part alone it looks fine; the lightest spot behind the letters is where it fails.

Why

Faint text is a common reason a page is hard to read. It costs everyone something in bright light, on a cheap screen or late in the day, and it shuts out people with low vision altogether. WCAG 2.2, 1.4.3 Contrast (Minimum) requires 4.5:1 between text and its background, and 3:1 for large text, which is about 24 px regular or about 18.5 px bold. The figures are not rounded: 4.49:1 fails. What counts is the colour the browser paints, so opacity, an alpha colour such as text-foreground/60, a translucent fill, a backdrop blur, a gradient and a photo all change the result. A pair of tokens that passes on paper can fail once one of them is laid on top. Text that shows on hover or focus, placeholder text and the labels and values in a chart are text too. The exemption is tied to being inactive, not to looking inactive: a control that still works must keep its text readable however it is styled.

Where a product has a light and a dark theme, we measure in both. People meet either one, so we treat each as the page; that is our way of applying the criterion, not words in it. Text that is used only as a symbol, such as an × on a close button, is judged as a graphic at 3:1 under 1.4.11 Non-text Contrast, which is VIS-004.

Do

  • Use text-muted-foreground as it is for secondary text, such as the publish date under each episode in a podcast host's Episodes list. Justified's contrast test (npm test in packages/tokens) checks it on the page and on muted in both themes. If the date should weigh less, make it smaller or move it, and leave its colour alone.
  • Know what the tokens promise. The test covers each *-foreground on its own fill, the status colours and primary as text on the page, and muted-foreground on the page and on muted. Every other combination is yours to measure, also when it is made of tokens.
  • Measure the composite. On a show page where the title Marrowfield Hours sits on the cover photo, put a scrim such as bg-black/60 under the title and check the title's colour against the lightest spot of the photo behind the letters, not against the average.
  • Check soft fills. text-destructive on bg-destructive/10 is a pair the test does not cover. With Justified's own values it measures about 5.6:1 in the light theme and 7.0:1 in the dark one. Before using such a pair, VIS-002 asks you to add it to the tokens and the test, so it is measured again whenever a colour changes.
  • Check hover and selected states. A table row with shadcn's hover:bg-muted/50 and data-[state=selected]:bg-muted keeps every cell readable on the new fill, its text-muted-foreground cells included: about 6.8:1 on the hover fill in the light theme and 7.3:1 in the dark one, and the selected fill is a tested pair. A product that changes the fills measures again.
  • Keep placeholder text at placeholder:text-muted-foreground, as Justified's Input, Textarea and NativeSelect do, and measure it again if the field sits on a tinted panel.
  • Fade a control only when it cannot be used. The disabled:opacity-50 in Justified's Button, Checkbox, RadioGroup, Switch and field controls applies only to a control that is off. A control marked aria-disabled="true" that does nothing when pressed counts as inactive too; the note that ACT-005 puts beside it is ordinary text and must pass.
  • Give chart text the same 4.5:1: axis labels, legend names and values printed on bars.
  • Aim a little above the minimum for thin or light font weights. They can look fainter than their colour suggests. This is our own advice.

Don't

  • Put opacity-50 or opacity-60 on a timestamp, a helper line or an empty-state sentence. muted-foreground at 50 % on the page measures about 2.3:1 in the light theme and 2.9:1 in the dark one.
  • Add opacity to a token that already passes, as in text-muted-foreground/70 (about 3.5:1 on the light page) or text-foreground/50 (about 3.4:1 on the light page).
  • Fade a whole card, row or button that still works to say "older", "not chosen" or "loading in the background". The text inside fails, and the exemption does not apply because the element is not inactive.
  • Use raw palette classes such as text-gray-400 or text-slate-500 without measuring them in each theme. A block of bg-blue-50 text-blue-600 with no dark: variant keeps its own contrast, but it stays a light block on the dark page, where text and parts around it were never checked against it. Which colours to use at all is VIS-002.
  • Put white text over a photo with no scrim and check it only against the photo's darkest part.
  • Set text in a sticky header with bg-background/70 backdrop-blur and test it only over an empty page, not over the content that scrolls beneath it.
  • Offer a high-contrast theme the person has to switch on, and let the default fall short. The web has no system setting a page can count on to switch it for them, so we ask the default presentation to reach the level; that is our own choice.
  • Count a 20 px heading in font-medium as large text. It needs 4.5:1.

Exceptions

  • Inactive controls. Text in a control that cannot be used at that moment. When to switch a control off at all is ACT-004 and ACT-005.
  • Decoration and logos. Text that is pure decoration, text no one can see, incidental text inside a photo with a lot else in it, and a logo or brand name. A logo set faint by the product's own choice, and not by its brand rules, is not exempt.
  • Visited links. The colour may change after a visit, but each link colour still needs 4.5:1 against the page. How a link stands out from the text around it is VIS-003b.
  • Neighbouring rules. Which token goes on which fill is VIS-002. Borders, icons and chart marks are VIS-004, which also measures them in every state. The focus indicator is KBD-001. The danger button's text is in DLG-005, and the required marker in FRM-005.

Verdict

Requirement. Only the judges decide; the expert witnesses are shown but do not vote. How verdicts work

Stances on VIS-001
SourceRoleStancePage
WCAG 2.2LawRequires1.4.3 Contrast (Minimum)
WCAG 2.2LawSupports1.4.11 Non-text Contrast
Material DesignJudge SupportsAccessibility designing: Color contrast
Apple Human Interface GuidelinesJudge SupportsAccessibility
Color
Carbon Design SystemJudge SupportsAccessibility: Color
Color
GOV.UK Design SystemExpert witness SupportsColour
Nielsen Norman GroupExpert witness SupportsLow-Contrast Text Is Not the Answer, by Katie Sherwin

Each stance links to the page it rests on, read on the date in the source register. This page never repeats what a source says; read the source itself.

History

  • Version 1.0.1, : Points to VIS-004 for measuring edges and marks in every state.
  • Version 1.0.0, : First version.

Last checked against the other rules for conflicts on .

More in Colour and motion: 11 rules and 0 guidelines · All rules