What a Screen Reader Hears — Web Fundamentals

A screen reader (a program that reads pages out loud) says the name and the role of every part of a page. alt gives an image its name, <label> gives an input…

Mr. Tono can't see the screen. He uses a phone like yours, but his phone reads pages out loud. The program that reads them is called a screen reader. A screen reader only knows what is written in the HTML.

Name and role

For every part of a page, a screen reader says two things: its name and its role. The name comes first, then the role, which is the kind of part it is. "Send, button." "Email, edit text." "Clinic logo, image." Without the name or without the role, Mr. Tono has to guess.

The right tag already carries its own role, so you don't have to add a role yourself.

TL;DR: A screen reader (a program that reads pages out loud) says the name and the role of every part of a page. alt gives an image its name, <label> gives an input box its name, and <button> gives the role of a button.

⚡ Name and role

Meaning: A screen reader is a program that reads pages out loud. For every part of a page it says two things, its name and its role, such as "Send, button". A screen reader only knows what is written in the HTML.

⚡ An image needs a name

Write:

<img alt="Clinic logo">
Guess first: without alt, what do you hear when the screen reader reaches that image?

Only "image", or the file's name. You have to guess what the image shows.

Meaning: alt gives an image a name, here Clinic logo.

⚡ Input boxes and buttons

Write:

<label for="email">Email</label>

Meaning: A <label> gives a name to the input box that for points to, here Email. Without a label, all you hear is its role, "edit text", with no name. <button> gives the role of a button, while a <div> with an onclick (so that it can be clicked) is still read out as plain text.

What you will learn