Color Contrast Requirements
One important way we can meet our accessibility commitment is to ensure adequate color contrast in the design components created as part of our content and marketing efforts.
On the web, adequate color contrast is defined as meeting the minimum requirement in the Web Content Accessibility Guidelines (WCAG) AA standard. This standard applies to text that's in HTML, as well as any text that's part of an image.
This standard means there should be a minimum contrast ratio between the foreground text color and background color of:
- 4.5:1 or greater for body text
- 3:1 or greater for large text (24px regular weight or 18.67px bold)
Black text on a white background or vice versa has the greatest possible color contrast ratio of 21:1.
What is Color Contrast Ratio?
Color contrast ratio is a calculation of the difference in relative luminance, the perceived brightness or darkness of color, between two colors. The Science of Color Contrast describes more than you likely ever wanted to know about color contrast.
It's worth noting that you don't need to make these mathematical calculations yourself. There are tools out there such as the WebAIM Contrast Checker to verify that all colors are in compliance.
It doesn't matter which color is in the foreground versus the background, the contrast ratio between the two always remains the same.
Examples
Solid colors are easy. Calculating the contrast ratio is as simple as taking the background color and measuring it against the foreground color.
Gradient, pattern, or photo backgrounds can be difficult because there needs to be contrast between the foreground text color and any part of the image that touches it. It gets even more complicated when you resize your browser and realize that the background color moves independently of the text if the text is not part of the image.
There are other considerations when using text in images as covered in Making Images Accessible, but for now we'll focus on color contrast.