WCAG colour contrast explained

What the contrast ratio measures, how to calculate it by hand, which thresholds apply to text and interface components, and how to fix colours that fall short.

By the ColourPickr team at The AI Barn. Last reviewed 17 October 2026.

Why contrast matters

Text that is too close in brightness to its background is hard to read. It is hardest for people with low vision or colour vision deficiency, but also for anyone using a phone in sunlight or an old, dim screen. The Web Content Accessibility Guidelines (WCAG), published by the W3C, set minimum contrast levels so that text and controls stay readable for as many people as possible. The current version is WCAG 2.2.

The thresholds

WhatLevel AALevel AAASuccess criterion
Normal text4.5:17:11.4.3 and 1.4.6
Large text3:14.5:11.4.3 and 1.4.6
Parts of interface components and graphics needed to understand them3:1(no AAA level)1.4.11 Non-text Contrast

Large text means at least 18 point, or at least 14 point if bold. One point is 1⅓ CSS pixels, so this is about 24px, or about 18.7px for bold text. Ordinary 16px body text is normal text, even if it looks big on your screen.

Level AA is the level most organisations aim for and the level that most legal requirements refer to. AAA is stricter, and WCAG itself advises against requiring AAA for whole sites, because some content cannot meet every AAA criterion.

Some things are exempt from the text contrast rules: text in logos and brand names, text that is purely decorative or not visible, and text in inactive (disabled) controls. Non-text contrast applies to the parts needed to identify a control and its state, such as a text field's border, a checkbox outline or a focus indicator. It also covers the parts of charts and icons that carry meaning.

How the ratio is calculated

The contrast ratio compares the relative luminance of the two colours. Relative luminance is a number from 0 (black) to 1 (white) that estimates how bright a colour appears. There are three steps.

Step 1: convert each channel to the 0 to 1 range and linearise it

Divide each of R, G and B by 255. Screen values are gamma-encoded, which means they are not proportional to the amount of light, so each value is converted back to linear light:

  • if the value is 0.04045 or less, divide it by 12.92;
  • otherwise, calculate ((value + 0.055) ÷ 1.055) raised to the power 2.4.

Older copies of WCAG show a threshold of 0.03928 instead of 0.04045. The W3C corrected this in 2021 and notes that the change makes no practical difference for 8-bit colours.

Step 2: weight the channels

L = 0.2126 × R + 0.7152 × G + 0.0722 × B

The weights reflect how sensitive the eye is to each primary. Green contributes most to perceived brightness, and blue least.

Step 3: compare the two luminances

Contrast ratio = (Llighter + 0.05) ÷ (Ldarker + 0.05)

The 0.05 added to each side accounts for ambient light reflecting off the screen. It also means the ratio runs from 1:1, for two identical colours, to 21:1, for black and white: (1 + 0.05) ÷ (0 + 0.05) = 21.

Worked example: white text on #6366F1

  • Channels: 99, 102 and 241, divided by 255, give 0.3882, 0.4000 and 0.9451.
  • Linearised: 0.1248, 0.1329 and 0.8796.
  • L = 0.2126 × 0.1248 + 0.7152 × 0.1329 + 0.0722 × 0.8796 = 0.1851
  • White has L = 1, so the ratio is (1 + 0.05) ÷ (0.1851 + 0.05) = 4.467

That is just below 4.5, so white text on this colour fails AA for normal text but passes for large text and for non-text elements. Black text on the same colour gives (0.1851 + 0.05) ÷ 0.05 = 4.701, which passes AA for normal text.

WCAG does not allow rounding up to reach a threshold. A ratio of 4.499:1 does not meet 4.5:1. Our contrast checker therefore shows ratios cut off at two decimal places rather than rounded.

Useful reference points

Text on backgroundRatioNormal text AA?
#767676 grey on white4.54:1Yes, the lightest neutral grey that passes
#777777 grey on white4.47:1No, one step too light
#595959 grey on white7.00:1Yes, and AAA
#808080 mid grey on white3.94:1No (large text only)
#FF0000 pure red on white3.99:1No (large text only)
White on #0000FF pure blue8.59:1Yes, and AAA
#FFA500 orange on white1.97:1No
#FFA500 orange on black10.63:1Yes, and AAA

Two things stand out. First, a single step in each channel can decide a pass or fail. That is why you should always test exact values rather than guess. Second, saturated mid-tones such as pure red and orange perform worse against white than people expect, because their luminance is higher than they look.

The colour that works with both black and white text

Designers often want a brand colour that can carry both white and black text. The maths shows how narrow that target is. For a colour to reach 4.5:1 against both, its relative luminance must lie between 0.175 and about 0.183. The best any colour can manage against both at once is about 4.58:1, at a luminance of roughly 0.179. ColourPickr's default colour, with a luminance of 0.185, sits just above that band, which is why it fails narrowly with white text. In practice, decide whether a colour is a "light" or a "dark" background and pair it with text accordingly.

How to fix a failing pair

  1. Change lightness, not hue. Keeping the hue and saturation and moving the lightness usually keeps a colour recognisable. For #6366F1 text on white, darkening to #6265f1 is enough for 4.51:1, and #373aed reaches 7.02:1 for AAA. The contrast checker finds these colours for you.
  2. Use the brand colour where contrast rules are looser. Large headings, icons and borders need 3:1 rather than 4.5:1. A colour that is too light for body text may be fine there.
  3. Create text-safe variants. Many design systems define a darker version of the brand colour for links and text, and keep the original for backgrounds and decoration.
  4. Fix text on images properly. Add a solid or semi-transparent panel behind the text, or a gradient overlay. Then test against the worst part of the image, not the average.
  5. Check every state. Hover, focus, visited and selected states are new colour pairs. Placeholder text in a form field still needs 4.5:1 if users must read it.

What contrast checks do not tell you

  • Colour must not be the only signal. Success criterion 1.4.1 requires that information shown with colour is also available another way. For example, underline links in body text, or add icons and labels to error messages.
  • Font weight and size matter. A very thin font at 4.5:1 can still be hard to read. The formula does not know which font you are using.
  • The formula has known limits. It is a simple model, and it can rate some pairs, particularly involving dark colours or saturated mid-tones, differently from how they look. A newer method called APCA has been explored for a future WCAG 3, but WCAG 3 is still a draft. For conformance today, WCAG 2.2's formula is the one that counts.
  • Users can override colours. Some people use high-contrast modes or custom style sheets. Build pages that still work when colours change, for example by not hiding text with colour alone.

The UK legal context

This is general information, not legal advice. In the UK, public sector websites and apps are covered by the Public Sector Bodies (Websites and Mobile Applications) (No. 2) Accessibility Regulations 2018. Current GOV.UK guidance says that meeting WCAG 2.2 level AA is how they meet the requirement, alongside publishing an accessibility statement. Private organisations providing services are covered by the Equality Act 2010's duty to make reasonable adjustments for disabled people. That duty is not written in terms of WCAG, but WCAG AA is the usual benchmark for showing that a website is accessible.

Ready to test your own colours? Try the contrast checker, or open a colour in the colour picker to see how it performs with white and black text.

Frequently asked questions

What contrast ratio do I need for body text?

At least 4.5:1 for level AA, or 7:1 for AAA.

Does contrast apply to placeholder text?

Yes, if the text conveys information the user needs. Disabled controls are exempt.

Do logos need to meet contrast requirements?

No. Text that is part of a logo or brand name is exempt from the text contrast criteria.

Is #777777 on white accessible?

Not for normal text at AA. It scores 4.47:1. #767676 scores 4.54:1 and passes.