Screen reader support is an essential component of web accessibility. When you’re developing content, your goal is to provide screen reader users with the same essential experience as visual users — and in certain situations, that might mean hiding content from the accessibility API (application programming interface).
Of course, you shouldn’t hide anything from users unless you’ve got a very, very good reason. However, modern websites often have elements that cannot (or should not) be conveyed to assistive technologies.
Content may be hidden from assistive technologies by using display: none in CSS; the HTML5 hidden attribute; or aria-hidden=’true' in WAI-ARIA (Web Accessibility Initiative - Accessible Rich Internet Applications) markup.
Using CSS or HTML will hide the content visually and remove it from the accessibility tree. These attributes should only be used when you need to hide content from all users.
The aria-hidden attribute works differently. It removes the content from the accessibility tree, but does not change the visual appearance of your website. Assistive technologies may still announce the presence of the element.
You might use aria-hidden if your content falls into one of the following categories:
Only use aria-hidden when content is visibly rendered. If you use HTML hidden or the CSS display:none, you don’t need aria-hidden, since the content isn’t visible on the page — the content is already removed from the accessibility tree, so aria-hidden is redundant.
Related: How CSS Benefits Accessibility
Remember, while WAI-ARIA is helpful for accessibility, you’ll need to follow the best practices of ARIA when creating your content. Otherwise, you may unintentionally introduce accessibility barriers — particularly when using aria-hidden to prevent users from accessing something important.
Misusing aria-hidden may violate Success Criteria 4.1.2 of the Web Content Accessibility Guidelines (WCAG). This criterion requires all user interface components to have a name and role that can be programmatically determined.
Some tips to keep in mind:
For more guidance, review MDN Web Docs' WAI-ARIA guide.
Generally speaking, it’s a bad idea to hide content, but as we’ve discussed, there are defensible reasons for taking that step. Unfortunately, most automated accessibility tests aren’t capable of understanding the context of the aria-hidden attribute.
As such, automated tests will often flag aria-hidden as a potential accessibility issue. This doesn’t mean that you need to remove the attribute — you’ll simply need to evaluate each instance individually to make sure that you’re using it correctly.
Related: What WAI-ARIA “Hidden" Warnings Mean For Your Website
Remember, hidden content should always support the screen reader user’s experience. You might decide to hide logos, icons, or repetitive text, but you should never remove useful content. Assistive technology users deserve an equivalent experience, and it’s your responsibility to provide that experience.
We strongly recommend working with a digital accessibility partner if you’re inexperienced with ARIA, as poor markup can cause major usability issues. Your partner can use automated and manual testing to ensure that every hidden element is handled correctly.
The Bureau of Internet Accessibility can help you understand ARIA and build a long-term compliance strategy for your content. Send us a message to connect with our team.