Checking contrast ratios against WCAG

The preset colours are the ones of this website, content surface and body text.

The contrast ratio describes the distance between the brightness of two colours. It runs from 1 to 1 for two identical colours up to 21 to 1 for black on white. What counts is not the hue but the relative luminance. Two strong colours can therefore look lively next to each other and still fail.

WCAG names four values worth knowing:

  • Level AA, small text: 4.5 to 1
  • Level AA, large text: 3 to 1
  • Level AAA, small text: 7 to 1
  • Level AAA, large text: 4.5 to 1

Large text starts at 24 pixels, or at 18.7 pixels for bold type. Interface elements and meaningful graphics have their own value of 3 to 1, for the border of an input field, the focus ring or an icon that carries information.

Level AA is the usual benchmark. The European Accessibility Act has required it for many digital services since June 2025, and it makes sense where no law applies as well.

What to check on a page

Measuring body text on background is not enough. These pairings fail most often in practice:

  • muted text, such as dates, captions and hints below form fields
  • placeholder text in input fields, often set in light grey
  • links, when they differ from the text by colour alone
  • disabled buttons that are still meant to be readable
  • text over photos, where the background changes from image to image
  • hover and focus states, which are rarely checked
  • light and dark mode, each with its own colour pairs

Brand colours are the most common reason for weak contrast. A light orange or a mid grey usually comes from a print manual and was never measured against white or against the content surface. In such cases it helps to keep the colour for areas and define a darkened variant for text.

What the ratio does not say

A good value does not mean the spot is accessible. Colour must never be the only carrier of information. A required field marked in red also needs text, a chart in green and red needs labels or different line styles.

Font size and weight remain a separate decision too. Thin cuts look pale even at a sufficient ratio, because less area is covered.

Tools

  • the calculator above, with the level reached for small and large text
  • the Contrast Checker by WebAIM, with suggestions for adjusted colour values
  • the browser developer tools, where the colour picker in the inspector states the ratio next to the colour value

The source of the calculator is on GitHub and can be embedded into your own pages as a web component.

What else matters for accessible pages is in the post What makes a website accessible. The part no calculator finds is checked with a screen reader, described in Testing a website with VoiceOver.