What the Contrast Ratio Means
The contrast ratio is a single number comparing the lightness of two colors, your text and its background. It runs from 1 to 1 at the low end to 21 to 1 at the high end.
The scale for measuring the contrast of colors used in a design varies from 1 to 21. A contrast ratio of 1 to 1 means the colors are identical and so the text is 100% invisible to the user. The ideal ratio is 21 to 1.
Things at either extreme are mostly inaccessible. The guidelines give minimum ratios that have to be achieved in order for the text to be considered accessible. The larger the minimum ratio, the easier it is to read the text. Your goal is to ensure the text meets the minimum ratio needed for its size.
The AA and AAA Requirements
When talking about conformance levels to the Web Content Accessibility Guidelines (WCAG), AA and AAA are the two most relevant for this case. Most site implementations and laws target AA.
The needed ratio also depends on text size. Large text is easier to read. It gets a lower bar.
| Text type | AA (standard) | AAA (enhanced) |
|---|---|---|
| Normal text | 4.5 to 1 | 7 to 1 |
| Large text | 3 to 1 | 4.5 to 1 |
| UI components and graphics | 3 to 1 | not specified |
"Large text" has a specific meaning: at least 18 point, which is about 24 pixels, or 14 point bold, about 18.5 pixels bold. Anything smaller counts as normal text and needs the higher 4.5 to 1 ratio.
For the body text of your site, use a 4.5:1 ratio. For large headings use a 3:1 ratio. This will mostly satisfy all legal requirements. Reaching the requirements of AAA for an entire site can be challenging and may not be feasible for some designs.
How the Ratio Is Calculated
You won’t be able to calculate the ratio by hand for each color. Knowing the concept can be useful. The ratio is found by the relative luminance of the colors being compared.
Luminance is not simply an average of the RGB values. The human eye is more sensitive to green than it is to blue. So, in the equation to find luminance, the weight of green is greater than the weight of blue. The weight of red is in between the two. As a result, two colors can seem equally bright to our eyes but have different luminance values.
To find the contrast ratio, you divide the luminance value of the lighter color by the luminance value of the darker color plus a small constant. Then add the same constant to the denominator. This is often expressed as 1 to 21. Contrast is perceived difference in brightness. A common mistake is thinking that for contrast to exist, colors must be different. Failing to meet this contrast standard surprises a lot of people, as they often expect that two different colors would have enough contrast.
How to Pass
Here's the practical part. Meeting the standard is straightforward once you test.
There are web contrast checkers that let you input colors and tell you if they meet the standard. Enter your text and background colors to check contrast for each pair in your design.
Add more contrast to your design by darkening your text or lightening your background. When text is not easily legible against its background, contrast must be improved by moving the colors further apart.
Don’t use color to express ideas. Contrast also encompasses varying levels of brightness. Details shouldn’t be expressed using color alone since persons with color blindness wouldn’t be able to grasp it.
Text should be easy to read over all parts of an image, including the edges. A common pitfall in design is using text over an image. This happens because the color of the background may vary, affecting the readability of the text. Add a dark background to the text to solve this.
Test all the states. Body text may not be the only state that needs to be checked. You should also check links, placeholders, hover states and disabled states.
A Real-World Example
Imagine your brand color is a medium blue. You use it for body text on a white background. It appears to work in your eyes. You use it on your site. Then you get an email from a user with low vision who can’t read your site. You check the contrast. It’s a 3.1 to 1 ratio and fails the test.
You check the blue against white in a contrast checker and get a ratio of 3.1 to 1. To meet the minimum requirement of normal text to be accessible it should be at least a ratio of 4.5 to 1. You may think that the color looks good against the background because you have good vision. That may not be the case for others. You edit the blue to a darker shade to get a ratio of 4.6 to 1 against the background. Headings may stay the medium blue as the ratio only needs to be 3 to 1 for larger text.
That gap between "looks fine to me" and "passes the standard" is exactly why the measurable ratio exists.
How to Check Your Contrast
Never guess. A contrast checker gives you the exact ratio in seconds. You enter the two colors and it reports the number plus pass or fail for each level. The free [Denwix color contrast checker](here does this right in your browser.
For the official rules, the [WebAIM contrast guide](here is the most-referenced plain-language explanation. The [W3C's grasp document](here is the authoritative source for the AA requirement. Both are worth bookmarking.
The Bottom Line
The WCAG contrast ratio is a standard to help ensure text is legible to everyone. Aim for AA: 4.5 to 1 for normal text and 3 to 1 for large text with 7 to 1 for AAA. The ratio is found by the difference in lightness of your text and background. So, if you fail the test, you have to separate the two colors more. To ensure your gray text is legible, use a contrast checker to test all color combinations before finalizing your design.
Questions and Answers
What is the WCAG contrast ratio?
Also known as legibility ratio, it measures the difference in brightness of text to its background and is expressed as a ratio of 1 to 21. The higher the ratio the more legible the text is to users with low vision.
What contrast ratio is required for AA?
4.5 to 1 for normal text and 3 to 1 for large text. AA is the standard level most websites aim for and that many accessibility laws reference.
What contrast ratio is required for AAA?
7 to 1 for normal text and 4.5 to 1 for large text. AAA is the enhanced level, stricter than AA and harder to meet across an entire design.
What counts as large text in WCAG?
At least 18 point, about 24 pixels. @CAP@14 point bold, about 18.5 pixels bold. Anything smaller is treated as normal text and needs the higher 4.5 to 1 ratio.
How is the contrast ratio calculated?
The formula is to take the value of the lighter color and divide it by the value of the darker color. The colors are weighted by green, red and blue in that order to show how the human eye perceives brightness.
What is a good contrast ratio?
A ratio of 4.5 to 1 for body text meets AA accessibility. A ratio of 7 to 1 meets AAA. The max ratio for pure black text on a white background is 21 to 1. Aim for a ratio of 4.5 to 1 for body text.
How do I check my contrast ratio?
Use a contrast checker tool. Just add your text and background colors to find the exact ratio and see if it meets accessibility standards for both normal and large text for both AA and AAA levels.
Why does my light gray text fail contrast?
Because it's too close in brightness to the white background, giving a low ratio. Darkening the gray increases the contrast until it passes the needed minimum.
Does contrast apply to large headings too?
Yes, but large text has a lower bar, 3 to 1 for AA. Headings can use lighter colors than body text and still pass, since larger text is easier to read.
What ratio do buttons and icons need?
Meaningful graphics and UI components must have a contrast ratio of at least 3:1 against their background to be accessible to persons with moderate visual impairments. This is to ensure that controls and graphics can be easily identified by everyone.
Is 3 to 1 enough for body text?
No, a contrast ratio of 3:1 applies to large text only. Body text must have a contrast ratio of 4.5:1. Using a contrast ratio of 3:1 for small text fails the standard and is very hard to read.
How do I fix failing contrast?
Lighten the background and darken the foreground color until the contrast ratio is adequate. A contrast checker can be used to confirm the ratio.
Can I rely on color alone to convey meaning?
No. Contrast handles brightness, but color-blind users may not distinguish hues. Pair color cues with icons, labels. Underlines so details isn't lost.
How do I handle text over an image?
Adding a dark background or a backing behind the text to create a solid color will give a enough contrast ratio, especially if the image behind the text has a light color. Text directly on a picture often fails to meet this requirement.
Does contrast ratio affect SEO?
Not exactly, but good contrast improves many aspects of a product that increase engagement like usability and accessibility. There are overlapping elements between accessibility and quality. Improving contrast is mostly good practice.
What is relative luminance?
Also called color difference, it defines the perception of brightness of a color. To calculate contrast ratio you need to find the relative luminance of both colors.
Why does my design look fine but fail the check?
Just because you can’t see the contrast with your eyes doesn’t mean there isn’t any. Always test to ensure adequate contrast.
Do I need AA or AAA for my website?
AA is the goal for most sites and apps and satisfies most legal requirements. Meeting AAA is very challenging and should not be the main focus.
What's the maximum contrast ratio?
The ratio is 21 to 1. This ratio equates to pure black text on a pure white background. There are many other combinations that also meet this requirement.
Does placeholder and disabled text need to pass contrast?
Placeholder text should also meet contrast requirements because users read placeholders. Disabled elements do not need to meet contrast requirements. It is best practice to keep them as visible as possible.