Skip to content
easeweb
Search topics

aria-label on divs and spans that screen readers often skip

A product list puts star ratings and a free-delivery icon in spans with an aria-label, but a plain span can't be named, so many screen readers say nothing.

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: No vision:Free delivery or not?
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?

BrokenLabels on spans that can't be named
  • 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 the words on an element that can carry them

Before
BrokenLabels 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>
What is wrong2 points

The stars and the truck are background images drawn by CSS, so each span is empty.

  • Many screen reader users hear the product name and nothing about its rating or delivery. Each span is empty, so it holds no text for a screen reader to read.
  • The aria-label doesn't make up for it. The span has no role, and a span with no role can't be named, so its label may never be read.
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>
How it is fixed2 steps
  1. Add role="img" to each star and truck span. It is the smallest change: one attribute on each element.
  2. Keep each aria-label as it is. The span is now one image, and an image can be named, so screen readers read "Rated 4 out of 5, image" and "Free delivery, image".

This fixes the Before and passes 1.1.1 and 4.1.2. It works only because the spans hold nothing but a picture. role="img" hides everything inside it, so never put it on an element that contains text or a link. The words still exist only for assistive technology, and the truck still means nothing to a sighted shopper who doesn't know it.

Easily confused
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. A label written with a misspelled attribute, or on a role ARIA doesn't define, is a different failure, covered in invalid ARIA that misleads screen readers. A rating people set, rather than one they read, needs stars a keyboard can choose, covered in star ratings that keyboards and screen readers skip. 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.

EaseWeb service

Fixed it? Keep it from coming back.

I turn guides like this one into rules your coding agents follow and checks your CI runs. Then I retest by hand with a keyboard and screen readers, periodically.

See the service