Web accessibility tutorials Guidance on how to create websites that meet WCAG
Jump to the navigation

Complex Images

Status: This is an in-progress, unapproved draft.

Complex images contain substantial information – more than can be conveyed in a short phrase or sentence. These are typically:

  • graphs and charts, including flow charts and organizational charts;
  • diagrams and illustrations where the page text relies on the user being able to understand the image;
  • maps showing locations or other information such as weather systems.

In these situations a two-part text alternative is required. The first part is the short description to identify the image and, where appropriate, indicate the location of the long description. The second part is the long description – a textual representation of the essential information conveyed by the image.

In certain situations the composition of the image may also be needed as part of the long description, but only where it’s important that the user understand the image construction. This page shows several possible approaches that can be used to provide both short and long descriptions.

Image containing substantial information

This bar chart of website visitor statistics has a short description of “Bar chart showing monthly and total visitors for the first quarter 2014 for sites 1 to 3”. It’s in the alt attribute and identifies the image. The long description details the information, including scales, values, relationships and trends that are represented visually. For example, since the declining values for site 1, consistent values for site 2, and increasing values for site 3 are highlighted through the bar chart, this information must also be included in the long text description.

Example

Bar chart showing monthly and total visitors for the first quarter 2014 for sites 1 to 3

Here the longdesc attribute contains the URI of a page containing the long description.

Code snippet:
<img
	src="chart.png"
	alt="Bar chart showing monthly and total visitors for the first quarter 2014 for sites 1 to 3"
	longdesc="2014-first-qtr.html">

If the long description is published on the same page as the image, the longdesc value can simply contain a fragment identifier (“hash link”) to the long description.

Code snippet:
<img
	src="chart.png"
	alt="Bar chart showing monthly and total visitors for the first quarter 2014 for sites 1 to 3"
	longdesc="#chart-longdesc">
[…]
<div id="chart-longdesc">
	[…]
</div>

Note: Both Firefox and Chrome browsers are working on implementations that will make the longdesc linked long description location reachable by all users. Currently, and in other browsers, it’s only available to screen reader users.

This approach provides a text link next to the image. The link text makes both the destination and the association with the image clear.

Code snippet:
<p>
	<img
		src="chart.png"
		alt="Bar chart showing monthly and total visitors for the first quarter 2014 for sites 1 to 3">
	<br>
	<a href="2014-first-qtr.html">Example.com Site visitors Jan to March 2014 text description of the bar chart</a>
</p>

Note: This approach is well supported in all browsers and ensures that everyone has access to the data as well as the image, no matter what browser or assistive technologies they may use.

Describing the location of the long description in the alt attribute

If the long description is on the same page as the image and its location can be accurately pinpointed by being described, the alt attribute can include location information.

Code snippet:
<p>
	<img
		src="chart.png"
		alt="Bar chart showing monthly and total visitors for the first quarter 2014 for sites 1 to 3. Described under the heading Site visitors full text.">
</p>
[…]
<h4>Site visitors full text</h4>
[…]

Structurally associating the image and its adjacent long description (HTML5)

The HTML5 <figure> element can be used to enclose both the image and its long description. The long description (presented as headings, text and a table) is explicitly associated to the image by using role="group" on the containing <figure> element.

Code snippet:
<figure role="group">
	<img src="chart.png"
		alt="Bar chart showing monthly and total visitors for the first quarter 2014 for sites 1 to 3, described in full below.">
	<h2>Trends</h2>
	<p>Site visitors for the first  ...</p>
	<h2>Statistics</h2>
	<table>
		<caption>Example.com Site visitors Jan to March 2014</caption>
		<tr></tr>
	</table>
</figure>

Structurally associating image and long description with aria-described-by

The WAI-ARIA aria-described-by attribute can be used to link the description to the image. The value of the attribute is the id of the element with the description.

Code snippet:
<img src="chart.png"
	aria-described-by="image-description"
	alt="Bar chart showing monthly and total visitors for the first quarter 2014 for sites 1 to 3.">

<div id="image-description">
	<p><strong>Trends:</strong> Site visitors for the first  ...</p>
	<p><strong>Statistics:</strong>
	<table>
		<caption>Example.com Site visitors Jan to March 2014</caption>
		<tr></tr>
	</table>
</div>

Techniques: