Colour contrast checker for text (WCAG)
Light grey on white looks refined on the designer's screen and cannot be read in sunlight out on the street. The accessibility guidelines put a figure on that difference. Enter your two colours and see whether they pass.
This site's colours
How it reads
Large text, 24 px
Normal text, 16 px. Open Monday to Friday, 9:00 to 18:00.
15.88:1
contrast ratio
- AA · normal text · 4.5:1Pass
- AA · large text · 3:1Pass
- AAA · normal text · 7:1Pass
- AAA · large text · 4.5:1Pass
- Non-text elements · 3:1Pass
What the contrast ratio is
It is a number between 1 and 21 that compares the lightness of two colours. 1:1 is two identical colours; 21:1 is black on white. It is calculated with the formula from the W3C's Web Content Accessibility Guidelines (WCAG): the relative luminance of the lighter colour plus 0.05, divided by that of the darker one plus 0.05.
The formula does not depend on which colour is the text and which the background: black on yellow gives the same result as yellow on black.
What figures you need to reach
WCAG 2.2 sets these minimums:
- Level AA, normal text: 4.5:1.
- Level AA, large text: 3:1. Large text is 18 point (about 24 px) or more, or 14 point (about 18.5 px) or more if it is bold.
- Level AAA, normal text: 7:1. Large text: 4.5:1.
- Non-text elements, such as the border of a field or an icon that carries meaning: 3:1 against whatever is next to them.
What is left out
Logos and text that is part of a brand have no contrast requirement. Neither does purely decorative text or the text of a disabled button.
And the figure is not everything: text that passes at 4.6:1 in a very thin, small typeface is still hard to read. At small sizes it is better to have margin to spare, not to sit on the limit.
A real case: this site's colours
The “This site's colours” buttons load the four pairs this site uses. The ink on the paper gives 15.88:1 and the grey of the secondary text, 6.62:1: both pass AA at any size.
Vermilion on the paper gives 2.86:1 and does not pass even for large text. That is why no word on this site is written in vermilion: it is used as the background of the buttons, with the text in ink on top, which gives 5.55:1.
How to use the suggestion
When the pair does not reach 4.5:1, the tool darkens or lightens the text colour, without changing its hue, to the first value that passes, and shows it for you to copy. It is a starting point: always look at the result with your actual typeface.
Frequently asked questions
What level should a business website meet?
AA is the usual reference and the one required by the accessibility rules that build on WCAG. AAA is a more demanding target, reasonable for the main text.
Does it work for text on top of a photo?
The formula compares two flat colours. Over a photo you have to measure against the lightest and the darkest area behind the text, or put a plain background under the text.
Why 4.5 and not another figure?
The W3C explains it in its documentation: 4.5:1 compensates for the loss of contrast sensitivity of a person with visual acuity of approximately 20/40, which is common from a certain age onwards.
The guide that explains it
A fast website on mobile: how to measure it and what slows it. What Core Web Vitals are, how to measure your website's speed on mobile, what slows it down and what to fix first, with a checklist.