WCAG Color Contrast Explained: AA vs AAA and How the Ratio Works

What the WCAG contrast ratio measures, the 4.5:1, 3:1 and 7:1 thresholds, what counts as large text, and how to fix failing colours without losing your brand.

Updated September 29, 2026 6 min read

Use the free Color Contrast CheckerCheck WCAG AA/AAA contrast of text and background with fix suggestions

The brand colour looks great on the mockup, but light grey placeholder text is hard to read on a laptop in daylight, the white label on the green button disappears for some users, and an accessibility audit comes back with a long list of "insufficient contrast" findings. Colour contrast is one of the most common accessibility failures on the web, and one of the easiest to measure objectively.

This guide explains what the WCAG contrast ratio actually measures, which thresholds apply to which elements, how the number is calculated, and practical ways to fix colours that fail while keeping them recognisably yours.

What the contrast ratio measures

The Web Content Accessibility Guidelines (WCAG) define contrast as a ratio between the relative luminance of two colours: how bright each one appears, weighted for human vision. The ratio runs from 1:1 (identical colours, invisible text) to 21:1 (black on white).

Hue does not enter into it directly. Red text on a green background of the same brightness scores close to 1:1, even though the colours look different to many people. That is intentional: people with common forms of colour vision deficiency cannot separate those hues, so only a difference in lightness helps everyone.

The thresholds

WCAG 2.1 (and 2.2, which keeps the same contrast rules) sets these minimums:

Element Level AA Level AAA
Normal body text 4.5:1 7:1
Large text 3:1 4.5:1
UI components and meaningful graphics 3:1 not defined

AA is the level most laws, policies and procurement rules refer to. AAA is stricter and is usually applied selectively, for example to long-form reading content.

What counts as large text

"Large" means at least 18 point (24 CSS pixels) at regular weight, or at least 14 point (about 18.66 CSS pixels) in bold. A 16px bold label is not large text, so it needs 4.5:1.

What the non-text rule covers

The 3:1 rule for UI components applies to things a user needs to perceive to operate the page: input borders, focus indicators, icons without text labels, checkbox outlines and chart lines that carry meaning. It does not apply to disabled controls, logos, or purely decorative images.

How the ratio is calculated

For each colour, convert the 0-255 sRGB channels to linear light, weight them, and add them up to get relative luminance. Then compare the lighter (L1) with the darker (L2):

contrast = (L1 + 0.05) / (L2 + 0.05)

Here is the whole calculation in JavaScript:

function luminance(hex) {
  const [r, g, b] = hex.match(/\w\w/g).map((h) => {
    const c = parseInt(h, 16) / 255;
    return c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
  });
  return 0.2126 * r + 0.7152 * g + 0.0722 * b;
}

function contrast(a, b) {
  const [hi, lo] = [luminance(a), luminance(b)].sort((x, y) => y - x);
  return (hi + 0.05) / (lo + 0.05);
}

console.log(contrast("#767676", "#ffffff").toFixed(2)); // 4.54
console.log(contrast("#999999", "#ffffff").toFixed(2)); // 2.85

The weights show why some colours are tricky. Green contributes about 72% of perceived luminance and blue only about 7%, so a mid green is much brighter than a mid blue. White text on a typical medium green often fails, while white on a similarly "strong" blue passes.

#767676 is a well-known reference point: it is about the lightest grey that passes 4.5:1 on white. The popular #999999 placeholder grey does not come close.

Check colours with the tool

The Color Contrast Checker calculates the ratio, shows a live preview and suggests the nearest passing colours.

  1. Open the Color Contrast Checker. Enter the Text (foreground) colour and the Background colour. You can type HEX, rgb(), hsl() or a CSS colour name, or use the colour swatch.
  2. Use the swap button between them to test the reverse combination, such as white text on a coloured button versus coloured text on white.
  3. Check the preview panel: a large heading, body text, a small line, a bordered button and a link, all in your colours.
  4. Read the Contrast ratio and the five verdicts: AA · normal text, AAA · normal text, AA · large text, AAA · large text and AA · UI components & icons.
  5. If something fails, look at Nearest passing colours. The tool keeps the same hue and saturation and moves lightness as little as possible, offering Text for AA, Text for AAA and Background for AA. Click one to apply it.

Fixing contrast without losing your brand

Adjust lightness, not hue

A slightly darker or lighter version of the brand colour usually passes and still reads as the same colour. That is exactly what the nearest-colour suggestions do. Keep the original shade for large headings, borders or decorative accents where 3:1 is enough, and use the adjusted shade for text.

Build a paired palette

Define each brand colour with a "text-safe" partner in your design tokens: the brand green for backgrounds and illustrations, a darker green for text and links. The colour converter helps express both in HEX, RGB and HSL, and the HTML colour codes reference is handy for picking neutrals.

Test every state

Hover, focus, visited and disabled states each have their own colours. Focus indicators in particular must meet 3:1 against the surrounding background. When you design buttons with the CSS button generator, check both the normal and hover colours.

Text on images and gradients

Contrast must hold at the point where text sits. On a photo or a CSS gradient, test the lightest area behind the text, or add a solid or semi-transparent overlay to guarantee it.

Pitfalls

Transparent colours

A colour with opacity blends with whatever is behind it. The ratio depends on the blended result, so measure the final colour as it actually renders (a browser colour picker or DevTools can sample it).

Passing the number but still hard to read

Contrast is one factor. Very thin fonts, small sizes, and long lines of low-weight text can be hard to read even at 4.5:1. Treat the thresholds as a minimum.

Dark mode

A palette that passes on white will not automatically pass on a dark background. Check each theme separately.

Future standards

A different contrast method, APCA, has been discussed for a future version of WCAG. It is not part of WCAG 2.x, so audits today still use the ratios above. Check the current official guidance if your organisation adopts a newer standard.

Frequently asked questions

What contrast ratio do I need for WCAG AA?

4.5:1 for normal text, and 3:1 for large text and for user interface components such as input borders and icons.

What is the difference between AA and AAA?

AAA requires higher contrast: 7:1 for normal text and 4.5:1 for large text. AA is the commonly required level; AAA is a stricter goal often applied to key reading content.

Does contrast apply to placeholder text?

Yes. Placeholder text is text, so it needs 4.5:1 at normal sizes. Many default placeholder greys fail.

Do logos need to meet contrast requirements?

No. Text that is part of a logo or brand name is exempt, as is purely decorative text.

Is black on white the best choice?

It has the maximum ratio of 21:1, but some readers find pure black on pure white glaring. A very dark grey on off-white still passes AAA comfortably.

Try it now: Color Contrast Checker

Loading tool…