aria-hidden="true": Best Practices
When to use aria-hidden=true for improved accessibility.
You’ve probably come across the aria-hidden="true"
attribute. It’s one of those handy little tools that can make a big difference for folks using screen readers or other assistive technologies.
But what exactly does it do, and how can you use it to make your website more accessible? In this blog post, we’re going to break it all down in everyday language, share some practical examples, and answer some common questions.
What’s This aria-hidden="true" Thing Anyway?
First off, let’s get the basics out of the way. ARIA stands for Accessible Rich Internet Applications, which is just a fancy way of saying it’s a set of tools (attributes, really) that help make web stuff more accessible. Specifically, aria-hidden="true"
is an attribute you slap onto an HTML element to tell screen readers and other assistive tech, “Hey, ignore this part—don’t read it out loud or let users interact with it through accessibility tools.”
Here’s the kicker, though: it only hides things from assistive technologies. Visually, the element stays right where it is on the page. So, sighted users see it just fine, but screen readers act like it doesn’t exist. Pretty cool, right? But that also means you’ve got to use it wisely, which we’ll get into soon.
Why Does It Matter?
You might be wondering, “Why would I want to hide something from a screen reader?” Great question! Accessibility is all about making sure everyone can use your site, including people who rely on screen readers to navigate. Sometimes, there’s stuff on the page—like decorative icons or content that’s not relevant right now—that could clutter up the experience or confuse users if it’s read out loud. aria-hidden="true"
lets you clean that up, keeping things simple and focused for everyone.
Think of it like tidying up your living room before guests arrive. You don’t toss out the furniture, but you might tuck away the random junk so it’s not in the way. That’s what aria-hidden="true"
does for your website.
When Should You Use aria-hidden="true"?
Alright, let’s get practical. Here are some real-world situations where aria-hidden="true"
comes in clutch, complete with examples you can wrap your head around.
1. Hiding Decorative Bits and Bobs
Websites love throwing in little visual flourishes—icons, background images, you name it. Those can look great, but they don’t always add meaning for screen reader users. Take a button with an icon next to some text, for example:
<button>
<i class="icon-save"></i> Save
</button>
That little save icon? It’s just eye candy—the word “Save” tells you everything you need to know. Without doing anything, a screen reader might say, “Save icon, Save,” which is repetitive and kind of annoying. Let’s fix that:
<button>
<i class="icon-save" aria-hidden="true"></i> Save
</button>
Now, the screen reader skips the icon and just says “Save.” Cleaner, clearer, and no extra noise. This works for anything decorative—think social media icons next to text links or little stars in a rating display that don’t need to be announced separately.
2. Keeping Inactive Content Out of the Way
Ever used a tabbed interface, a carousel, or a modal popup? These are all spots where some content is “active” (visible and relevant) while other stuff is “inactive” (hidden or waiting its turn). You don’t want screen readers stumbling over the inactive bits—it’s like trying to read a book while someone’s flipping pages on you.
Let’s say you’ve got a carousel with three slides, but only one is showing at a time:
<div class="carousel">
<div class="slide" aria-hidden="true">
<p>Slide 1: Old news.</p>
</div>
<div class="slide" aria-hidden="false">
<p>Slide 2: Hot topic right now!</p>
</div>
<div class="slide" aria-hidden="true">
<p>Slide 3: Coming up next.</p>
</div>
</div>
Here, aria-hidden="true"
keeps the inactive slides (1 and 3) quiet, so the screen reader only announces Slide 2. When the user moves to another slide, you’d update the aria-hidden
values (usually with JavaScript) to match what’s visible. This keeps the experience smooth and logical.
Same deal with tabs or modals—hide the stuff that’s not in play right now, and you’ve got a happier user.
3. Cutting Out Redundant Chatter
Sometimes, you’ve got elements that make sense visually but turn into a jumbled mess when read aloud. Imagine a star rating system:
<div class="rating">
<span>★★★★☆</span>
<span>4 out of 5 stars</span>
</div>
A screen reader might say, “Star, star, star, star, empty star, 4 out of 5 stars.” That’s a mouthful! Let’s streamline it:
<div class="rating">
<span aria-hidden="true">★★★★☆</span>
<span class="sr-only">4 out of 5 stars</span>
</div>
(The .sr-only
class hides the text visually but keeps it for screen readers—more on that trick later.) Now, the screen reader just says, “4 out of 5 stars.” It’s concise, it’s clear, and it skips the visual fluff that doesn’t add value.
4. Managing Modal Madness
Modals—those pop-up windows that demand your attention—are another spot where aria-hidden="true"
shines. When a modal opens, you want the user focused on it, not the stuff underneath. Here’s a basic setup:
<div id="main-content">
<p>Welcome to my site!</p>
</div>
<div id="modal" role="dialog" aria-modal="true" style="display: none;">
<p>Sign up now!</p>
</div>
When the modal pops up, you can hide the main content from screen readers:
document.getElementById('main-content').setAttribute('aria-hidden', 'true');
document.getElementById('modal').style.display = 'block';
Close the modal, and flip it back:
document.getElementById('main-content').removeAttribute('aria-hidden');
document.getElementById('modal').style.display = 'none';
This keeps the screen reader focused on the modal while it’s open, avoiding confusion with the background content. It’s like putting blinders on a horse—keeps everything on track!
Best Practices: How to Use It Right
aria-hidden="true"
is awesome, but it’s not a magic wand. Here’s how to use it without tripping over your own feet.
1. Know What You’re Hiding
When you slap aria-hidden="true"
on something, it hides that element and everything inside it. There’s no “unhiding” a child element if the parent’s hidden—it’s all or nothing. For example:
<div aria-hidden="true">
<p>This is hidden.</p>
<p aria-hidden="false">This is still hidden—sorry!</p>
</div>
That second paragraph? Still invisible to screen readers because the parent rules the roost. If you need to hide some parts but not others, don’t nest them under one aria-hidden="true"
—keep them separate.
2. Watch Out for Focusable Stuff
You can put aria-hidden="true"
on things like buttons or links, but it’s tricky. The element stays focusable (meaning users can tab to it), but screen readers won’t say what it is. That’s a recipe for confusion. Imagine tabbing to a mystery button with no clue what it does!
If something shouldn’t be interacted with, make it unfocusable too—maybe set tabindex="-1"
or remove the href
from a link. Or, if it’s just temporarily out of action, consider aria-disabled="true"
instead, which tells screen readers it’s there but not usable right now.
3. Pair It with Visual Hiding (When Needed)
Since aria-hidden="true"
doesn’t affect how things look, you might need CSS to hide stuff visually too. Like this:
.hidden {
display: none;
}
<div class="hidden" aria-hidden="true">
<p>Gone from sight and sound!</p>
</div>
Here’s the thing: display: none
already hides stuff from screen readers, so aria-hidden="true"
might seem redundant. But adding it makes your intent crystal clear, which is always a win for maintainability.
4. Test, Test, Test
Accessibility isn’t a “set it and forget it” deal. After adding aria-hidden="true"
, fire up a screen reader (like NVDA or VoiceOver) and check how your page sounds. Did you hide the right stuff? Is anything important missing? Testing ensures you’re not accidentally silencing something users need.
Common Mistakes
Even with good intentions, it’s easy to mess up. Here are some slip-ups to avoid.
1. Hiding the Good Stuff
Don’t use aria-hidden="true"
on things users need—like form fields, navigation links, or key instructions. If a screen reader can’t find it, you’ve just locked someone out. Double-check that whatever you’re hiding is truly optional or redundant.
2. Forgetting About the Kids
Since aria-hidden="true"
on a parent hides all its children, you might accidentally bury something important. Always scope it to exactly what you mean to hide, not a big container with mixed content.
3. Mixing It Up with Other ARIA Tricks
aria-hidden="true"
isn’t the same as role="presentation"
. The latter strips an element’s meaning (like turning a div
into a neutral blob), but it doesn’t hide the content inside. aria-hidden="true"
goes full ninja—everything’s gone from the accessibility tree. Pick the right tool for the job!
4. Assuming It Fixes Everything
Hiding stuff doesn’t automatically make your site accessible. It’s one piece of the puzzle—focus management, proper labels, and semantic HTML all need love too. Think of aria-hidden="true"
as a helper, not a cure-all.
Wrapping It Up
There you have it—a deep dive into aria-hidden="true"
and how it can level up your website’s accessibility. Whether you’re tidying up decorative clutter, managing dynamic content, or keeping screen readers focused, this attribute is a powerhouse when used right.
Just remember: hide what’s not needed, keep the essentials loud and clear, and test your work to make sure it sings for everyone.
Accessibility isn’t about checking boxes—it’s about making your site welcoming to all. So grab aria-hidden="true"
, play around with it, and see how it can smooth out the experience for your users. Got a carousel to tame or a modal to wrangle? You’ve got this!
FAQ
Does aria-hidden="true" hide the element visually?
No, it only hides it from screen readers and assistive tech. The element stays visible on the page unless you use CSS to hide it too.
Is aria-hidden="true" the same as using role="presentation"?
No way! role="presentation" removes an element’s meaning but keeps its content accessible. aria-hidden="true" hides the element and all its content completely.
Does aria-hidden="true" on a parent element hide all its children?
Yes, it hides the parent and everything inside it. No way to unhide a child if the parent’s got aria-hidden="true".
Can I use aria-hidden="true" on focusable elements?
You can, but it’s not ideal. The element stays focusable but silent to screen readers, which can confuse users. Better to make it unfocusable or use something like aria-disabled if it’s not usable.

Yucel is a digital product maker and content writer specializing in full-stack development. He is passionate about crafting engaging content and creating innovative solutions that bridge technology and user needs. In his free time, he enjoys discovering new technologies and drawing inspiration from the great outdoors.