Not everyone uses a mouse to explore a website. Good HTML must also make sense through a keyboard or screen reader.
What You Need to Know
Overriding the role of a semantic element can hide information that a screen reader needs. If a native element already fits the task, leave its role alone instead of replacing it with a generic one.
Try the Example
Take a look at the example. We’ll explain the important lines right below it.
<h2 id="main-heading">Account settings</h2>
<section aria-labelledby="main-heading">
<label for="display-name">Display name</label>
<input id="display-name" name="display-name">
<button type="button">Save draft</button>
</section>
Let’s Read the Code
- <h2>: A heading divides the page into understandable parts.
- <section>: A section groups content with a shared topic.
- id: An id uniquely identifies an element on this page.
- aria-labelledby: Aria-labelledby uses the text of another element as the accessible name.
What the example shows: Use ARIA relationships to add meaningful names, not to erase correct native roles.
What Happens in the Browser?
Try this with Tab and Shift+Tab. If you can, inspect the accessibility tree too; appearance alone does not tell the whole story.
What does assistive technology receive? The example includes aria-labelledby. These relationships can explain names, states, or descriptions when used correctly. They do not automatically move focus, listen for clicks, or create keyboard handling.
Your Turn
Move through the example without a mouse. Read each control name and current state aloud as if describing it to a friend.
Common Beginner Mistakes
- Expecting ARIA alone to create keyboard behavior or make a control interactive.
- Overriding a native role can remove useful accessibility information or create contradictions.
Key Takeaways
- Overriding the role of a semantic element can hide information that a screen reader needs.
- <h2>: A heading divides the page into understandable parts.
- A meaningful HTML element is usually a stronger starting point than adding an ARIA role to a generic div. Also check what happens using only the keyboard.