Course contentsShow
← Web Development
Lesson 2660 of 2,98247. Data VisualizationFree lesson

ARIA Labels and Roles for Charts

Apply role='img' and aria-label to chart containers; describe the chart's purpose for screen readers.

ARIA Labels and Roles for Charts

You'll learn how to make chart containers understandable to screen readers by assigning semantic roles and descriptive labels.

Why Charts Need ARIA

Visual charts are meaningless to screen reader users without textual context. A complex SVG or Canvas chart is just a blob of graphics code to assistive technology. By applying ARIA (Accessible Rich Internet Applications) attributes, you give screen readers a way to announce what the chart represents and its purpose.

The role='img' Attribute

When you create a chart container (whether SVG, Canvas, or div wrapping a library chart), assign role="img" to tell assistive technology "treat this entire element as a single image." This signals that the content inside is a unified visual representation, not interactive sub-elements to navigate through.

<svg role="img" aria-label="Sales revenue by quarter for 2024">
  <!-- Chart paths, bars, etc. -->
</svg>

The aria-label Attribute

The aria-label provides the actual description screen readers will announce. Write it like you're explaining the chart's purpose to someone who can't see it:

<div role="img" aria-label="Pie chart showing market share: Product A 45%, Product B 30%, Product C 25%">
  <!-- Canvas or library chart -->
</div>

Think of it like this: role="img" tells what kind of thing it is, while aria-label tells what information it conveys.

Writing Effective Labels

Include the chart type, what's being measured, and key insights if the dataset is simple. For complex charts, describe the overall trend or purpose rather than every data point (use a data table alternative for full details).

<svg role="img" aria-label="Line chart of temperature trends showing a 15-degree increase from January to June">

Key Takeaway: Apply role="img" and aria-label to chart containers to describe their purpose and content for screen reader users, transforming visual-only information into accessible context.