Accessible names
Last updated: 20 November 2024
There are several methods to put an accessible name on HTML elements like <button>, <h3>. <a> and <input>. You migh be interested ti read the article about methods of applying accessible names to elements first.
My article describes what a screenreader should read when you use attributes like label, aria-label, aria-labelledby, aria-describedby.
Exact words for roles and reading order in the examples might differ per screenreader. The buttons and input fields are tested with NVDA. In the 3rd column the texts are shown what NVDA says when the interactieve item gets focus.
code | implemented | screenreader |
---|---|---|
|
Hello button | |
|
Goodbye button | |
|
Goodbye | Goodbye button |
|
Goodbye | Goodbye Hello button |
|
Goodbye | Hello button Goodbye |
bad example
|
Hello
|
clickable Hello |
bad example
|
Hello
|
Hello button |
code | implemented | screenreader |
---|---|---|
|
First edit, blank | |
|
Error message | First edit Error message blank |
bad example
|
First edit blank | |
Strange. This seems to work, while you should not put an aria-label on a span. |
First required edit blank | |
|
First edit required blank | |
bad example
|
edit blank | |
bad example
|
Second edit blank | |
bad example
|
Second edit blank | |
bad example
|
edit blank | |
bad example
|
First edit blank | |
bad example
|
||
bad example
|
edit blank | |
bad example
|
Second edit blank | |
|
First edit blank | |
weak example
|
First |
First edit blank |
bad example
|
First
First
|
uncertain for some browsers |
|
First
|
First edit blank |
|
First
Error: Error message
|
First Error: Error message edit blank |
|
Error: Error message
|
First edit Error: Error message blank |