Colour

Overview – Colour

Colour enhances the design of Web content by increasing its aesthetic appeal, its usability, and its accessibility. As useful as it is, colour must not be the only way information is conveyed. Colour conveys information when it emphasizes text, distinguishes between visual elements, and distinguishes interactive elements from static elements. People who are colourblind, have low vision or are blind must be provided a text alternative of the information conveyed by colour. The same is true for those using text-only, limited colour, or monochrome displays.

To accommodate the needs of all, ensure colour is not the only way information is conveyed. Also, ensure your CSS colour design is customizable, so users can compensate for painfully bright and low contrast colours via the operating system or browser by applying a custom style sheet.

Information conveyed by colour

Information conveyed by colour must have an accurate text alternative.

In this bad example, colour alone communicates severity. There are no text labels. A legend / key below the table uses colour to define the severity values.

Defect report
# of defects Severity Status
20   Open
30   Closed
15   In progress

Red = High, Yellow = Medium, Green = Low

Figure 1: An inaccessible table that uses colour alone to identify severity levels. No text labels are provided.
Defect report
# of defects Severity Status
20 Open
30 Closed
15 In progress

Red = High, Yellow = Medium, Green = Low

Figure 2: The colours from Figure 1 as seen by a user with protanopia (red-blind). Bronze instead of red. Beige instead of yellow. lightly darker bronze instead of green.
Defect report
# of defects Severity Status
20 Open
30 Closed
15 In progress

Red = High, Yellow = Medium, Green = Low

Figure 3: The colours from Figure 1 as seen by a user with deuteranopia (green-blind). Brown instead of red. Beige instead of yellow. Slightly darker brown instead of green.

  Good example: Coloured table data with text labels

The table uses colours to convey information with text labels that ensure the meaning is perceivable.

Defect report
# of defects Severity Status
20 High Open
30 Medium Closed
15 Low In progress
Figure 4: An accessible table that combines colour and text label in the same cell to convey information

  Bad example: Error field indicated only with colour

In this bad example, the red text is the only indication of an error. Red and black are practically indiscernible for some users with colour blindness.

Also, the red text fails to meet the WCAG’s minimum contrast ratio requirement of 4.5:1 (basic red, or #FF000, has a contrast ratio of 4:1 with background white, #FFFFFF).

Finally, without additional semantic markup it would be impossible for screen reader users to identify the problem field.

Please complete the fields marked in red

User Login Information (Required)

  Good example: Highlighted form field error with explanatory text

In this example, validation highlights an error with both a colourful background and explanatory text “Error 1: This field is required.”

Screenshot of form fields showing a highlighted validation error
Figure 5: After validation, a bold text error message on a pinkish grey background displays at the problem field.

This example is from WET guide: Form validation

  Bad example: Colour alone communicates information

In the bad example below, the chart legend uses colour alone to identify the different bar columns.

Bad example of a bar chart with legend that uses colour alone to identify the different bar columns.

  Good example: Information communicated through colour and pattern

In the good example below, the chart legend uses colour and patterns to identify the different bar columns. The alternative text adequately describes the data conveyed in the bar chart.

Bar chart depicting game console sales in first 3 months of 2021: in January 84 Nintendo, 66 PlayStation; in February 48 Nintendo, 22 PlayStation; in March 25 Nintendo, 57 PlayStation.

Alt text: Bar chart depicting game console sales in first 3 months of 2021: in January 84 Nintendo, 66 PlayStation; in February 48 Nintendo, 22 PlayStation; in March 25 Nintendo, 57 PlayStation.

  Bad example: Colour-coded information not communicated through alternative text

In the bad example below, the chart legend uses colour and patterns to identify the different bar columns. However, there is no alternative text for screen reader users.

Bad example of a bar chart image with no alternate text.

HTML

<img src="images/sales-to-march-2021.png" alt="">

Users with low vision and colour blindness need to distinguish links and controls from neighbouring text. The easiest way to do this is with an underline on the link and a border on a control.

When colour is used as the only way to identify a link (meaning the underline has been removed) or a control, two conditions must be met:

  • 3:1 contrast between the body text and the link text or control.
  • A "visual cue" (not just a colour 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, but you could also provide a background colour or border or outline.

Note that this is only an issue when the link or control and the body text appear together. It doesn’t apply to links or controls in the header or stacked in a menu, where they’re understood to be links or controls by their position on the page.

These requirements are in addition to the minimum contrast requirement of 4.5:1 between foreground text and background. It can be difficult to find a link or control colour that has both a 3:1 contrast with black body text and a 4.5:1 contrast with a white background. WCAG Technique G183 lists colour values that do, in Example 1.

In this example, the hyperlink text is differentiated from the surrounding normal text by underlining.

The IT Accessibility Office (ITAO) remains to be a provider of adaptive technology and an advocate for inclusiveness of people with disabilities in the workplace.

  Good example: High contrast with a visual effect on hover and focus

This example avoids a static underline by:

  • Using blue (#3333FF) as the link colour, which has
    • a 3.1:1 contrast with neighbouring black text (just exceeds the minimum 3:1)
    • a 6.9:1 contrast with the background white (well exceeds the minimum 4.5:1)
  • As an additional visual cue on hover or focus, the link text is set in a very high contrast (21:1) of white against black background.

The IT Accessibility Office (ITAO) remains to be a provider of adaptive technology and an advocate for inclusiveness of people with disabilities in the workplace.

Results from the Colour Contrast Analyser
Screenshot of Colour Contrast Analyser app showing contrast ratio 3.1:1
Figure 6: The Colour Contrast Analyser finds a 3.1:1 contrast ratio between the links’ blue (hex #333FF) and the neighbouring text’s black (hex #000000).
Screenshot of Colour Contrast Analyser app showing contrast ratio 6.9:1
Figure 7: The Colour Contrast Analyser finds a 6.9:1 contrast ratio between the links’ blue (hex #3333FF) and the background white (hex #FFFFFF).

After receiving keyboard focus or mouse hover

Screenshot of Colour Contrast Analyser app showing contrast ratio 21:1
Figure 8: The Colour Contrast Analyser finds a 21:1 contrast ratio between the links’ white (hex #FFFFFF) and the background’s black (hex #000000).

  Bad example: Colour alone distinguishes links from text

In this bad example, the blue foreground colour indicates that the last two icons are links. The blue has the required 3:1 contrast with the black of the neighbouring text, but it has no additional visual effect on hover or focus.

  Good example: Border supplements colour to distinguish links from basic text

In this good example, the borders on hover and focus indicate that the last two icons are links.

Customization of interface colour and contrast

Some users with sensitivity to brightness or with low vision will expect to be able to modify colours. Whenever possible, use native controls and features of HTML. That allows users to customize interface colour and contrast for the visible UI components.

  Good example: Button using CSS

In this example, the appearance of the button is set with CSS rules, including colours. The values are easily overridden by a custom user style sheet.

View the CSS
.button-ex {
   background-color: #0065CB;
   border: none;
   color: white;
   padding: 10px 25px;
   text-align: center;
   text-decoration: none;
   display: inline-block;
   font-size: 36px;
   margin: 4px 2px;
   cursor: pointer;
}

  Bad example: Button using an image of text

When buttons use an image of text, user style sheets are not able to customize the text properties, including foreground and background colours. Screen magnification pixelates and blurs images of text, diminishing readability.

HTML

<button style="border: none; background: none;">
   <img src="images/image17.jpg" alt="Next" class="img-responsive"/>
</button>

Related WCAG resources

Related WCAG resources

Success criteria

Techniques

Failures

Back to top