Skip to content

Guides

How to check that text is readable on a colour

Artem Okhten · Updated

You have a colour for a button or a banner and need to know whether white or black text on it is readable. The answer is a number: the contrast ratio, from 1:1 (no contrast) to 21:1 (black on white).

The numbers to aim for

  • 4.5:1 for normal text. This is WCAG level AA, the usual requirement.
  • 3:1 for large text: 24 px regular, or about 19 px bold.
  • 7:1 for normal text at the stricter AAA level.

Check a colour

Enter the colour in the Color Explorer. The contrast section shows its ratio against white and against black, with a pass or fail for AA and AAA.

A common surprise: white text on #3b82f6, a very common button blue, is 3.68:1. That passes for large text and fails for body text. Black text on the same blue is 5.71:1. White on orange #f97316 is 2.80:1 and fails even as large text.

When your colour fails

Under the ratios the page offers adjusted colours: the same hue with the lightness moved until white or black text reaches 4.5:1. Click one to open it.

Use the adjusted shade where text sits on the colour, such as buttons and labels. Keep the original for large areas with no text on them.

Traps that pass the eye test

  • Grey text on white. Placeholder and caption text are the most common failures.
  • Text over photos. The ratio changes across the image, so put a solid or semi-transparent block behind the text.
  • Mid-tone colours such as orange, green and sky blue, which can fail with both white and black at body size.

Pick the rest of the palette

The explorer builds a 50–950 ramp from your colour in OKLCH, where equal steps look equally different. Take text colours from the dark end and backgrounds from the light end, and check the pair you choose.

Try it in the Color Explorer. It runs in your browser and nothing is uploaded.