Skip to content
mentoor

Topic 2 of 6 · 4 min read

Checking colour contrast against WCAG

Goal: Check text and interface contrast against WCAG 2.2 AA with a contrast checker and fix a palette an AI wrongly said passes.

Contrast is a measured ratio between two colours, so check it with a contrast checker, never with a model's opinion. A chat model can say "this passes AA" about colours that fail.

Check yourself · 1 of 3

What is the WCAG 2.2 AA minimum contrast ratio for normal-sized body text?

Choose one answer

Why it matters

Low contrast makes text hard to read for people with low vision, colour-vision differences, a dim screen or bright sunlight. WCAG, the W3C's web accessibility standard, sets minimum ratios. Level AA is the usual legal and contractual target. Models do not calculate the ratio. They predict text that sounds right, so they often give a confident number that is wrong.

How to do it

  1. Know the AA thresholds in WCAG 2.2. Normal text needs at least 4.5 to 1. Large text (at least 24 px, or about 18.7 px bold) needs 3 to 1. Interface parts, such as input borders, icons and focus rings, need 3 to 1 against what is next to them.
  2. Take the real values. Use the exact hex codes from the design, for the text and for the background it sits on. Check each state: default, hover, disabled and focus.
  3. Run a checker. The WebAIM Contrast Checker takes two colours and gives the ratio and pass or fail for each level. Browser developer tools and design tools show it too.
  4. Check colour is not the only cue. An error shown only by a red border, or a chart that only works by hue, fails people who cannot tell the colours apart. Add an icon, a label or a pattern.
  5. Ask the model to propose, then verify. It is useful for suggesting darker or lighter variants close to your brand colour. Check every suggestion.

Before and after

Before: The model says: "Grey #999999 on white has a contrast ratio of about 5:1, so it passes AA."

The real ratio is about 2.8 to 1. It fails for body text.

After: Darken to #767676 on white, which a checker reports at about 4.5 to 1, then confirm it.

What goes wrong

  • The model checks the text colour against white but the real background is a tinted card or an image.
  • Placeholder text, disabled-looking links and light-grey helper text are skipped because they feel secondary.
  • Dark mode is not checked, so a palette that passes in light mode fails in dark.
  • A palette passes for text but the form field borders, at 1.5 to 1, vanish for some users.

Examples

A palette audit

A designer asks an assistant to review five pairs. It says all pass. A checker run shows the grey helper text on white at about 2.8 to 1 and the orange button label on white at about 3 to 1, a pass only if the label is large.

Fix the helper text by darkening it, and increase the button label size or darken the orange, then rerun the checker on each pair.

Colour as the only cue

A form marks invalid fields with a red border only. Users who cannot tell red from grey get no signal.

Add an error icon and a text message beside the field, such as "Enter a date like 24/12/2026", so the cue does not depend on hue.

Key points

  • Contrast is a calculated ratio, and a language model does not calculate it reliably.
  • WCAG 2.2 AA needs 4.5 to 1 for normal text, 3 to 1 for large text and 3 to 1 for interface parts such as borders and icons.
  • Check the real hex values, on the real background, in every state and in both light and dark themes.
  • Colour must not be the only way to show an error, a selected state or a chart series.
  • Use the model to suggest variants and a checker to approve them.

Common mistakes

  • Trusting a model's claim that a colour pair passes without running a checker.
  • Checking text against the page background and not the card or image behind it.
  • Skipping hover, disabled, focus and dark-mode states.
  • Forgetting that borders, icons and focus rings also need 3 to 1.

Check yourself · 2 of 3

An AI assistant says your light-grey text on white "passes AA with a ratio of about 5 to 1." What is the right next step?

Choose one answer

Check yourself · 3 of 3

A form shows invalid fields by turning the border red. What should you add so the cue does not depend on colour alone?

Choose one answer

Practice items, not counted towards your mastery.

Start here