Icon-Only Buttons and Links
You'll learn how to make icon-only buttons and links accessible by adding labels that screen readers can announce but sighted users don't see.
The Problem with Icon-Only Controls
Modern interfaces often use icon-only buttons (like a hamburger menu ☰, trash can 🗑️, or magnifying glass 🔍) to save space and create clean designs. While sighted users recognize these icons visually, screen reader users hear nothing meaningful — just "button" or "link" without context.
Imagine walking into a room where every door looks identical. That's what an unlabeled icon button "feels" like to someone using a screen reader.
The Solution: Visually Hidden Labels
You combine two techniques you've already learned:
- The CSS visually hidden pattern (which hides content from sight but not from screen readers)
- Descriptive text inside the button or link
<button>
<span class="sr-only">Open menu</span>
<svg><!-- hamburger icon --></svg>
</button>
<a href="/search">
<span class="sr-only">Search products</span>
<svg><!-- magnifying glass icon --></svg>
</a>
The .sr-only class uses the clip pattern you learned, making "Open menu" and "Search products" invisible on screen but announced by assistive technology.
Alternative: aria-label
For simple cases, you can also use aria-label directly on the control:
<button aria-label="Open menu">
<svg><!-- hamburger icon --></svg>
</button>
Both approaches work. The visually hidden text method is often preferred because the text exists in the HTML (better for translation tools and testing), but aria-label is more concise.
Key Takeaway: Every icon-only button or link needs a text label for screen readers — either through visually hidden text or aria-label — describing what the control does, not what it looks like.