Course contentsShow
← Web Development
Lesson 1019 of 2,98218. Accessibility FundamentalsFree lesson

aria-label: Providing Accessible Names

Adding accessible labels to elements that lack visible text or need clarification.

aria-label: Providing Accessible Names

What you'll learn: How to use aria-label to give elements meaningful names that assistive technologies can announce to users.


The Problem: Elements Without Clear Names

Sometimes you create interactive elements—like icon buttons, search fields, or navigation links—that don't have visible text labels. A magnifying glass icon button makes sense visually, but a screen reader user hears nothing useful like "button" with no context. That's not helpful.

Think of it like this: Imagine walking into a room full of unlabeled light switches. You'd have to flip each one to figure out what it controls. aria-label is like adding a label to each switch so you know immediately what it does.


What aria-label Does

The aria-label attribute provides an accessible name directly to an element. Screen readers and other assistive technologies will announce this label instead of (or in addition to) the element's visible content.

<button aria-label="Close dialog">
  ×
</button>

Here, screen readers announce "Close dialog, button" instead of just "times symbol, button."


Common Use Cases

Icon-only buttons:

<button aria-label="Search">
  <svg><!-- magnifying glass icon --></svg>
</button>

Ambiguous links:

<a href="/article/123" aria-label="Read more about accessibility basics">
  Read more
</a>

Elements needing clarification:

<nav aria-label="Main navigation">
  <!-- links -->
</nav>

When NOT to Use It

Don't use aria-label when visible text already exists and is sufficient. It overrides visible content, which can confuse users when what they hear doesn't match what they see.


Key Takeaway: Use aria-label to provide clear, descriptive accessible names for elements that lack visible text or need additional context for assistive technology users.