Skip to content
easeweb
Search topics

aria-label on divs and spans that screen readers skip

A product list puts each star rating and its free-delivery icon in a span with an aria-label, but a plain span cannot be named, so many screen readers say nothing where the rating should be.

WCAG 2.2
SC 1.1.1ASC 4.1.2A
Required by
Section 508 · EN 301 549 (EU)
Broken <span class="icon-truck" aria-label="Free delivery">
The accessibility problem illustrated: The screen reader skips this label.
01

The problem

Screen reader users can't tell how a product is rated or whether delivery is free.

02

Try it

Compare the cards with what a screen reader reads.

The panel shows what a screen reader that skips a label on a span reads. Can you tell how each product is rated, and which one ships for free?

Broken Can you fix this?

  • Linen apron

  • Canvas tote

A screen reader that skips the label says:

  1. list, 2 items
  2. Linen apron, heading level 3
  3. Canvas tote, heading level 3

A recreated demo. The broken version is intentionally inaccessible.

03

The fix

Put each label where it can be read: on an element that can be named, or in the content as text.

  1. 1Use aria-label only on elements whose role can be named: controls, landmarks, images and frames.
  2. 2Give a graphic role="img" with its label, or put its meaning in the content as text.
  3. 3Hide the graphic itself with aria-hidden="true" when its meaning is written beside it.
Before Labels on spans that can't be named
<ul class="products">  <li class="card">    <h3>Linen apron</h3>    <span class="stars stars-4" aria-label="Rated 4 out of 5"></span>    <span class="icon-truck" aria-label="Free delivery"></span>  </li>  <li class="card">    <h3>Canvas tote</h3>    <span class="stars stars-3" aria-label="Rated 3 out of 5"></span>  </li></ul>
After

Give each graphic a role that can be named

<ul class="products">  <li class="card">    <h3>Linen apron</h3>    <span class="stars stars-4" role="img" aria-label="Rated 4 out of 5"></span>    <span class="icon-truck" role="img" aria-label="Free delivery"></span>  </li>  <li class="card">    <h3>Canvas tote</h3>    <span class="stars stars-3" role="img" aria-label="Rated 3 out of 5"></span>  </li></ul>

Fixing this with an AI coding assistant? Get this guide as Markdown

04

Verify the fix

4 checks, no mouse.

Test with: Screen reader

0 of 4 checked

Record the OS, browser and assistive-technology versions, the build, the date, and the actual result of each step. Repeat whenever a shared component that renders labels changes.

Limits

This is a starting pattern, not a guarantee for every application. Class names are placeholders, and the stars and truck stand for any graphic drawn with CSS or an icon font. Screen readers change how they treat prohibited names between versions, and some read them in one mode but not another, so a pass with one screen reader proves little. Whether a label carries something people need, or only repeats visible text, depends on the page and needs a person to judge. Test the complete journey with your target assistive technology.

This is a recreated teaching example, not a finding about a named client. The code is a starting pattern: test it in your own product. No completed assistive-technology test is claimed here.

Keep this fixed as your code changes.

Turn guides like this into rules your coding agents and CI follow, then have the result retested with a keyboard and screen readers.

How retests work