aria-hidden: Removing from Accessibility Tree
You'll learn how to hide decorative or redundant content from screen readers while keeping it visible on screen.
Why Hide Content from Screen Readers?
Not everything you see on a webpage needs to be announced to screen reader users. Some elements are purely decorative (like icon fonts, background shapes, or repeated text) and would clutter the experience if announced. The aria-hidden attribute lets you remove these elements from the accessibility tree—the structure assistive technologies use to navigate your page—while keeping them visually present.
Think of it like background music in a movie. Sighted viewers see decorative elements naturally as "background," but screen readers treat everything equally unless you tell them otherwise.
How aria-hidden Works
The aria-hidden attribute accepts two values:
aria-hidden="true"— Removes the element and all its children from the accessibility treearia-hidden="false"— Explicitly includes the element (rarely needed; this is the default)
<!-- Decorative icon hidden from screen readers -->
<button>
<span class="icon" aria-hidden="true">★</span>
Save to Favorites
</button>
<!-- Redundant visual indicator hidden -->
<a href="/profile">
<img src="arrow.svg" aria-hidden="true">
View Profile
</a>
When to Use aria-hidden
- Decorative icons when text already conveys the meaning
- Duplicate content shown for visual emphasis but redundant aurally
- Presentational images created with CSS or font icons
- Visual separators like decorative borders or spacers
Critical Warning
Never use aria-hidden="true" on focusable elements! A keyboard user could focus something they can't hear, creating confusion.
Key Takeaway: Use aria-hidden="true" to hide decorative or redundant elements from screen readers, ensuring assistive technology users only hear meaningful content.