Keyboard users can focus elements that screen reader users can't perceive, creating a confusing mismatch in experience.
When you apply aria-hidden="true" to an element, you're telling assistive technologies to ignore it completely. But if that element contains focusable items like links, buttons, or form fields, keyboard users can still tab into them. The screen reader goes silent while focus lands on an invisible element—users hear nothing and have no idea where they are on the page.
aria-hidden="true"<a href>)<button>)<input>, <select>, <textarea>)tabindex="0" or positive tabindexRemove elements from the tab order while keeping aria-hidden:
<!-- Before: Focusable link inside aria-hidden -->
<div aria-hidden="true">
<a href="/terms">Terms of Service</a>
</div>
<!-- After: Link removed from tab order -->
<div aria-hidden="true">
<a href="/terms" tabindex="-1">Terms of Service</a>
</div>
The inert attribute removes both focus AND aria-hidden in one step:
<!-- Modern approach: inert handles everything -->
<div inert>
<button>This button cannot be focused or seen by AT</button>
<a href="/link">This link is also inert</a>
</div>
inert is supported in all modern browsers and is the preferred solution for modal backgrounds, hidden menus, and off-screen content.
Sometimes the fix is rethinking your HTML structure:
<!-- Before: Icon with focusable link hidden -->
<div aria-hidden="true">
<svg>...</svg>
<a href="/download">Download</a>
</div>
<!-- After: Only hide the decorative icon -->
<div>
<svg aria-hidden="true">...</svg>
<a href="/download">Download</a>
</div>
For dynamic content like modals:
function openModal(modal) {
modal.removeAttribute('aria-hidden')
modal.removeAttribute('inert')
modal.querySelector('button, [href], input').focus()
}
function closeModal(modal) {
modal.setAttribute('inert', '')
// or: modal.setAttribute('aria-hidden', 'true')
// and add tabindex="-1" to all focusable children
}
<script setup>
const isMenuOpen = ref(false)
</script>
<template>
<div :inert="!isMenuOpen || undefined">
<nav>
<a href="/about">About</a>
<a href="/contact">Contact</a>
</nav>
</div>
</template>
undefined (not false) to remove the attribute entirely when not needed.display:none already hides from both, making aria-hidden redundant.inert to prevent focus escape.| Scenario | Solution |
|---|---|
| Modal backdrop/background | inert on background |
| Off-screen mobile menu | inert when closed |
| Decorative icons with nearby text | aria-hidden on icon only |
| Collapsed accordion content | inert when collapsed |
| Permanently hidden content | display: none (no ARIA needed) |
ARIA focus issues often appear alongside:
This issue commonly appears in modals, mobile navigation, and dynamically shown/hidden content across your site. Unlighthouse audits every page automatically, catching aria-hidden focus traps wherever they occur so you can ensure keyboard and screen reader experiences stay in sync.
Accessibility
Master web accessibility with Lighthouse. Learn how accessibility audits work, why they matter for users and SEO, and how to fix common issues.
HTML Lang Attribute
Learn how to fix missing lang attribute in Lighthouse accessibility audits. The lang attribute helps screen readers pronounce content correctly.