Understanding WCAG 2 Contrast and Color Requirements

Introduction

Contrast and color use are vital to accessibility. Users, including users with visual disabilities, must be able to perceive content on the page. There is a great deal of fine print and complexity within the Web Content Accessibility Guidelines (WCAG) 2 that can easily confuse web content creators and web accessibility evaluators. This article pulls together the terms and principles needed to understand WCAG 2 requirements for contrast and color.

WCAG 2 "Contrast Ratio"

In WCAG 2, contrast is a measure of the difference in perceived "luminance" or brightness between two colors (the phrase "color contrast" is never used). This brightness difference is expressed as a ratio ranging from 1:1 (e.g., white text on a white background) to 21:1 (e.g., black text on a white background). To give a frame of reference, on a white background…

  • Pure red (#FF0000) has a ratio of 4:1. I am red text.
  • Pure green (#00FF00) has a very low ratio of 1.4:1. I am green text.
  • Pure blue (#0000FF) has a contrast ratio of 8.6:1. I am blue text.

The contrast ratios and WCAG conformance for various color combinations can be evaluated using the WebAIM Color Contrast Checker.

Important

If text and background colors are inverted, the contrast ratio remains the same.

Three success criteria in WCAG 2 address contrast:

One additional success criterion, 1.4.1 Use of Color, references the contrast ratio as part of the requirement for links that are differentiated by color alone.

We will review these four success criteria in detail.

1.4.3 Contrast (Minimum)

This Level AA requirements reads:

The visual presentation of text and images of text has a contrast ratio of at least 4.5:1, except for the following:

  • Large Text: Large-scale text and images of large-scale text have a contrast ratio of at least 3:1;
  • Incidental: Text or images of text that are part of an inactive user interface component, that are pure decoration, that are not visible to anyone, or that are part of a picture that contains significant other visual content, have no contrast requirement.
  • Logotypes: Text that is part of a logo or brand name has no contrast requirement.

Here are some examples of text with almost almost exactly 4.5:1 contrast

  • Gray (#767676) on white
  • Purple (#CC21CC) white
  • Blue (#000063) on gray (#808080)
  • Red (#E60000) on yellow (#FFFF47)

For many of us, some of these combinations are not very readable. That is why 4.5:1 is a minimal contrast ratio. Additionally, WCAG only measures color luminance differences. There are many other aspects of color use that may impact perception and readability.

Important

WCAG requires "at least 4.5:1" contrast, so you cannot round a contrast ratio up to 4.5:1. For example, #777777 is a commonly-used shade of gray with a 4.48:1 contrast ratio. It does not meet the WCAG contrast threshold.

Images of text

These contrast requirements also apply to text within a graphic, called "images of text" in WCAG 2.

Example

The white text in the image below has insufficient contrast.

Image with white text on a light blue background. The text reads '50 most played songs by genre'

Outline and halo

Text effects, like outlines, can impact perceived contrast. WCAG 2 states that the color of a text outline or border can be used as the text or foreground color when measuring contrast.

text with a blue outline and solid blue text that have the same contrast ratio

A text glow/halo around the letters can be used as the background color.

text with a blue background and text with a blue glow have the same contrast ratio

While the examples above all have the same WCAG contrast ratio, those with solid foreground and background colors are likely more readable.

Exceptions

There are three exceptions to this 4.5:1 contrast requirement: large text, incidental text, and logotypes.

Large text

Large text is easier to read, so the contrast requirement is reduced to 3:1. WCAG defines large text as text that is 18pt and larger, or 14pt and larger if it is bold.

For example, the following are large texts that have a 3:1 contrast ratio:

  • Gray (#949494) 18 point text on white
  • Purple (#C86FF1) 14 point + bold text on white
Note
  • In web pages, pixels are much more common for text size than points. 18 points maps to 24 pixels and 14 points to approximately 18.67 pixels.
  • This applies to images of text as well, but it can be difficult to measure text size in an image.

Incidental

WCAG 2.0 defines four types of "incidental" text that are not required to meet the contrast requirements.

  • Inactive: An inactive element, like a disabled Submit button (), is identified visually by its lower-contrast state.
  • Pure decoration: Decorative text that is not meant to be read. An example of this might be a picture of a bookshelf on a library homepage. The titles of the books are not meant to be read by the user.
  • Not visible to anyone: Text that is meant to be hidden, like an invisible skip link would not need to meet any contrast requirements until it becomes visible.
  • Part of a picture that contains significant other visual content: Text that is not an important part of the information in the image, like a name tag on the shirt of a person in a photo of a party, does not need to meet any contrast requirements.
Note

To help determine if text in an image needs sufficient contrast, you might consider that any text that would be added to the image's alternative text should probably meet contrast requirements while text that would not be added to alternative text can usually be considered incidental.

Logotypes

Text that is part of a logo or brand name has no contrast requirement. If we look back at the example of an image of text used earlier, the Amazon music logo would be exempt.

The word 'music' is white on a light blue background, but it is part of the Amazon music logo.

Additional considerations

A couple important contrast considerations are not mentioned in 1.4.3.

Gradients, background images, and transparencies

Text over gradients, semi-transparent colors, and background images still need to meet contrast requirements, but WCAG does not provide any guidance on how to measure their contrast. We recommend testing the area where contrast is lowest.

Color changes on hover, focus, etc.

Text sometimes changes color while the user interacts with it using a mouse or keyboard. CSS can be used to define hover, focus, or active states for interactive elements. There is no mention of special consideration for these changes in text color, meaning text in all these states must still meet the same contrast requirements.

1.4.6 Contrast (Enhanced)

The only difference between this Level AAA success criterion and Level AA 1.4.3 is that contrast requirements are more stringent. It requires 7:1 contrast for normal text and 4.5:1 for large text. Although higher contrast is often recommended, this article focuses on 1.4.3 compliance throughout.

1.4.11 Non-text Contrast

WCAG 2.1 was published in June 2018. One new 2.1 success criterion moves contrast beyond just text. 1.4.11 Non-text Contrast (Level AA) reads:

The visual presentation of the following have a contrast ratio of at least 3:1 against adjacent color(s):

  • User Interface Components: Visual information required to identify user interface components and states, except for inactive components or where the appearance of the component is determined by the user agent and not modified by the author;
  • Graphical Objects: Parts of graphics required to understand the content, except when a particular presentation of graphics is essential to the information being conveyed.

There is one notable difference in how the contrast requirements are applied. 1.4.11 requires contrast "of at least 3:1 against adjacent color(s)," which means you may need to measure contrast in more than one place. A non-text element may have different contrast on one side than the other (like a wedge in a pie chart), or it may contain different-colored components that need 3:1 contrast with each other.

Example

A triangle-shaped icon with an exclamation mark is used to alert the user to something important.

icon

This graphic is composed of two important shapes—the exclamation mark and the triangle (usually reserved for alerts like these). That means there are 2 contrast ratios to consider:

  1. The contrast ratio between the white exclamation mark and the red triangle, which is greater than 3:1.
  2. The contrast ratio between the red triangle and the gray background, which is less than 3:1.

This icon does does not meet 1.4.11.

User Interface Components

There are two types of non-text elements that 1.4.11 says must have 3:1 contrast. The first are "User Interface Components," which are controls for distinct functions. For example, in a group of social media icons, each icon is a distinct user interface component.

Facebook, Twitter, Google+, YouTube, and Instagram icons

States

It isn't enough to measure the contrast of the default presentation of a user interface component. Each state of the component must also have 3:1 contrast. States are temporary changes in a component, usually because of a user interaction, such as hovering with a mouse or tabbing with a keyboard.

Example

When a user hovers over a custom checkbox, it turns bright blue (#00B0F0).

This checkbox has 2.5:1 contrast in the hover state, so it fails.

Except when "determined by user agent"

If you use the default styles provided by the browser, then these contrast requirements do not apply.

Example

In Chrome, the default border for a text box has 2.4:1 contrast:

First Name text box

This outline is well below the 3:1 threshold, but since this color was "determined" by the browser and was not customized by the author, it is exempt. Because of the low default contrast, we recommend using CSS to increase the contrast for text boxes and other form inputs.

The most common example of a low contrast "state" is the default outline that appears when an element has keyboard focus. This outline is a bright blue line in most browsers (Firefox is the exception with a dotted line). It is fairly distinctive and meets the 3:1 guidelines on a white background, but is less visible against some colors, and can be almost invisible against bright blue backgrounds.

Nearly invisible focus outline around the text 'Follow your interests'.

While there is some debate as to whether this is a WCAG 2.1 failure, it is still something you will want to evaluate and address. You can use the CSS :focus and outline properties to customize the focus indicator so it will have at least a 3:1 contrast ratio, while also matching your site design and aesthetics.

Note

If there is no visible indication of keyboard focus, this is a failure of 2.4.7 – Focus Visible (Level AA).

Graphical Objects

The second type of non-text element covered in this success criterion are "graphical objects". There are a couple key terms within this definition.

"Required to understand the content"

For something to be defined as a graphical object that needs 3:1 contrast, it must be "required to understand the content."

Example

A Twitter icon that is a link would need 3:1 contrast. But if the link also includes the word "Twitter" (with at least a 4.5:1 contrast ratio), then the icon is no longer required to understand the content, so it does not have any contrast requirement.

Light green Twitter icon followed by the word 'Twitter'

"…except when a particular presentation is essential"

Certain types of images may need to be presented in lower contrast so they don't lose meaning or purpose. A heat map must use low-contrast colors in some areas so that the underlying page is still visible.

Example

Heat map of a Wikipedia page

Real-life imagery, like photos and screenshots, also fall into this category, as do logos.

1.4.1 Use of Color

WCAG 2 does not prohibit any specific color or color combination, such as red and green. The previous success criteria require that text and non-text elements have sufficient contrast. Success Criterion 1.4.1, a Level A requirement, prohibits using color alone to present important content or instructions. It reads:

Color is not used as the only visual means of conveying information, indicating an action, prompting a response, or distinguishing a visual element.

This is a pretty straightforward recommendation.

Example

In this table of school assignments, the only indication that an assignment is missing or late is a background color. This is inaccessible to someone who is blind, and may be confusing or inaccessible to someone who is colorblind or that overrides page colors.

Screenshot of a spreadsheet where missing assignments are highlighted with a light red background, and late assignments have a yellow background.

One way to address this is to add a second column for the status of the assignment (missing, complete, or late). You can still use color to reinforce information, as long as color is not the only way this status is presented. In fact, the color highlights make the information more accessible to users who can see the color difference.

Screenshot of the repaired spreadsheet with a column indicating the assignment status.

Form instructions and errors

Color is often used in forms to identify required fields and form errors.

Example

A required form field that is left empty may be given a red border.

Screenshot of a form where the email address field has a red border, indicating there is an error.

The red border is color-reliant and not enough on its own. The form field will also need an icon:

an alert icon has been added to the empty email field

Or an inline error message:

an error message of 'E-mail address required' appears below the empty email field

Color-only identification of links

WCAG 2 contrast and color rules overlap in one place: when color is used as the only way to identify a link. This does not apply to every link on a page. For example, links in the header of a webpage are understood to be links based on their position in the page and the use of whitespace, distinct fonts, or other styling. This requirement applies in places where body text and link text appear together and color alone is used to identify links (meaning the underline has been removed).

For optimal accessibility and usability, maintain the underline on links. Otherwise, you will need to do the following:

  1. Ensure 3:1 contrast between the body text and the link text.
  2. Provide a "visual cue" (not just a color change) that appears on mouse hover and keyboard focus. The most common way to meet this is to underline the link on hover and focus.

These requirements are in addition to the 1.4.3 text contrast requirement of 4.5:1. Meeting all three of these requirements simultaneously can be difficult.

Tip

Use the Color-reliant Link Contrast Checker to check the contrast requirements for non-underlined links.

Example

A form ends with a line of text that reads: "By submitting this form, you agree to our Terms of Use." The dark gray (#2E2E2E) body text has 13.6:1 contrast on a white background. The blue (#0079AD) "Terms of Use" link has 4.8:1 contrast. Both the text and the link text meet the WCAG contrast requirements.

...but there is only 2.8:1 contrast between the body text and the link text. A slightly lighter shade of blue (#0081B8) would provide just over 3:1 contrast between the link and the body text:

... but the link now has less than 4.5:1 contrast with the background!

With many combinations of text and background colors, it is impossible to use non-underlined links and also meet all of the WCAG guidelines. This becomes increasingly difficult if the links change color on hover or focus. Each of the colors in these states must also have at least a 4.5:1 contrast ratio difference with the background. WCAG 2.0 and Link Colors on the WebAIM blog explores the WCAG requirements for link colors in more depth.