Track 03 · Lesson 5 of 8Building for everyone
Track 03 · Building for everyone
Screen readers
Lesson 5 of 8· 7 min
A screen reader turns the page into speech or braille. It can only announce what the code tells it: an element's name, its role (button, link, heading) and its state. See what it says for common mistakes and their fixes.
Hear the difference
Turn on Read aloud if your browser supports it
A save control
<div class="btn" onclick="save()">Save</div>“Save”
Read as plain text: no role, and Tab skips it, so keyboard users can’t press it.
A chart image
<img src="q3-sales-chart-final-v2.png">“q3 sales chart final v2 dot png, image”
With no alt text, many screen readers read the file name.
An icon-only close button
<button> <svg>…</svg> </button>“button”
It’s a button, but what does it do? The icon has no text.
An email field
<input type="email" placeholder="Email">“Edit text”
Placeholders aren’t reliable labels: some screen readers skip them, and they vanish as you type.
A link
To see our plans, <a href="/pricing">click here</a>.“click here, link”
Screen reader users often browse a list of all links. Ten “click here” links tell them nothing.
An error message
<label for="email">Email</label> <input id="email" class="red-border"> <span class="error-text">Invalid</span>“Email, edit text”
The red border and the word “Invalid” aren’t connected to the field, so they’re never announced.
A “Saved” message
<div class="toast">Saved</div>(silence)
It appears on screen, but nothing is announced. Screen reader users never learn it worked.
Announcements are simplified. NVDA, JAWS, VoiceOver and TalkBack each word things slightly differently.
Name, role, state#
Every control a screen reader meets is described by three things:
- Name: what it's called. It comes from the visible text, a
label,alttext, oraria-labelwhen there's no visible text. - Role: what it is, like button, link, checkbox or heading. Native elements have the right role built in.
- State: whether it's checked, expanded, disabled or invalid.
When any of the three is missing, the user hears "button" with no idea what it does, or "Save" with no idea it's clickable.
The first rule of ARIA#
ARIA attributes, like aria-label, aria-describedby and role, only change what's announced. They don't add keyboard support or behavior. So use the native element whenever one exists, and reach for ARIA to fill the gaps: naming an icon-only button, linking an error to its field, or announcing a status message.
Check yourself