How to check colour contrast on your website
Check text and controls against their backgrounds, fix common low-contrast colours and retest key pages and form states.
By Pithmark
Measure the colour of the text against the background it sits on. For WCAG 2.2 Level AA, aim for at least 4.5:1 for standard text and at least 3:1 for large text. Check buttons, form fields and error messages where customers actually use them, including states that appear after interaction.
Start with the pages customers need most
Pick a few pages that cover a full customer journey, such as a services page, its enquiry form and the confirmation or error screen. Include headings, body copy, links, field hints and button labels. Check any light and dark themes the site offers.
Use a contrast checker with the foreground and background colours from the rendered page. The browser inspector can show the styles applied to an element. If the background is an image, gradient or translucent layer, check the resulting colour behind the text where contrast is weakest, including how it changes on narrow screens.
Know which ratio you are checking
WCAG 2.2 Level AA requires 4.5:1 for standard text and 3:1 for large text, subject to the criterion’s exceptions. Large text is generally at least 18 point, or 14 point if bold, roughly 24 and 18.7 CSS pixels respectively. Compare against the threshold before rounding.
For example, grey #777777 on white is about 4.48:1. It falls below 4.5:1 for standard text. Changing that text to #666666 on white gives about 5.74:1. If a form field depends on its border to be identifiable, check that border separately. WCAG’s non-text contrast criterion generally requires 3:1 against adjacent colours for visual information needed to identify an active control or its state.
Fix the shared colour and retest the affected states
If several components share the same low-contrast colour, find where it is set in the theme or stylesheet. Check where else the colour is used before changing it. Darkening a text colour can help on white and reduce contrast on a dark background.
Open the revised page on mobile and desktop. Tab through links and fields to check that keyboard focus is visible. Trigger a form error and inspect the message and any state indicator. Record the page, element, colours and measured ratio so someone else can reproduce the check.
- Check text against the background it actually appears on.
- Test visible hover, focus and error states used in the journey.
- Recheck other components that use any colour you changed.
Common questions
- Is a homepage contrast scan enough?
- Use it as a starting point. Check other templates and states that a scan of the homepage would miss, such as checkout errors or keyboard focus on a contact form.
- Does passing these contrast checks make the site accessible?
- Contrast addresses one part of accessibility. A broader review also checks tasks such as keyboard navigation, understanding form errors and using assistive technology.
Sources
- W3C on WCAG 2.2 minimum text contrast
- W3C on WCAG 2.2 non-text contrast
- W3C’s first review of web accessibility
Researched with official sources and written with AI assistance.