A webpage should make sense even when someone cannot see its colors, pictures, or layout.
What You Need to Know
aria-label supplies a name directly; aria-labelledby borrows text from another element. The latter often keeps the accessible name aligned with words visitors can actually see.
Try the Example
Take a look at the example. We’ll explain the important lines right below it.
<h2 id="topics-title">Explore topics</h2>
<nav aria-labelledby="topics-title">
<a href="/html">HTML</a>
<a href="/css">CSS</a>
</nav>
Let’s Read the Code
- <h2>: A heading divides the page into understandable parts.
- <nav>: Navigation elements identify groups of important links.
- id: An id uniquely identifies an element on this page.
- aria-labelledby: Aria-labelledby uses the text of another element as the accessible name.
Read the named elements and attributes together. They explain how the browser connects this feature to the rest of the page.
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.
- ARIA changes what assistive technology is told; it does not automatically add keyboard controls, visual styling, or JavaScript behavior.
Key Takeaways
- aria-label supplies a name directly; aria-labelledby borrows text from another element.
- <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.