When and How to hide Elements from screen readers
People often ask when content should be hidden from assistive technologies, especially screen readers. In this article, I would like to offer an assessment. Some topics are controversial, while others are clear.Non-Informational Elements
Since the cognitive load for blind people increases with the number of elements, it makes sense for them to hide non-informational elements. Unlike sighted people, they cannot simply skip over recurring or superfluous elements. Decorative elements are generally hidden. In the context of digital accessibility, decorative elements are those that are purely visual and have no functional or informative purpose. They serve only an aesthetic purpose and do not contribute to the transmission of essential information. Examples of decorative elements are:- Background images or patterns: A background pattern or image that only serves to enhance the page.
- Decorative graphics: Icons, ornaments, or illustrations that have no additional meaning.
- Visual separators: Lines or graphics used for visual structuring but have no content-related meaning. This also includes spacer GIFs, such as those used in layout tables.
Elements Only Visible for a Short Time
With expandable elements such as menus or accordions, the content is often read aloud to blind people, even though it is still invisible to sighted people. This can be particularly problematic with extensive navigation: Imagine a navigation with dozens of elements. It is difficult for blind people to navigate within the navigation hierarchy and find the navigation point they need. Another problem can be overlays or dialog boxes, such as cookie layers: Often, the background is grayed out and locked for sighted people, so they interact with the overlay first. However, blind people can interact with the content using the keyboard: They can read it and also access links. This is due to incorrect integration of the overlays. This becomes problematic when data needs to be entered, as forms usually cannot be submitted if the overlay is still open. Overlays do not use the hiding technologies mentioned below, but rather focus traps. Focus traps intentionally keep the focus on an element until it has been interacted with. Only content that is visually visible should be displayed. This means that if a navigation element or accordion content is visible to sighted people, it should also be visible to blind people. This does not include content that is displayed on mouse-over. It should be displayed when elements receive screen reader focus. In my opinion, UI elements that are currently inactive should also not be hidden, for example, submit buttons, which are disabled as long as the required fields are not filled in. Blind people must be able to learn a graphical user interface. This is made more difficult for them if they cannot perceive all elements, regardless of whether they are currently available or not.How to hide content from screen readers?
There are several methods to hide content from screen readers: aria-hidden="true"- What it does: Elements with this attribute are completely hidden from screen readers, but remain visually visible.
- When to use: For decorative elements or content that is irrelevant to screen reader users.
How to test?
As always, I advise newbies against testing directly with screen readers. Rather, using the accessibility tree is, in my opinion, the best method for checking whether content is hidden or visible to screen readers.Relevant WCAG Success Criteria
The following WCAG criteria are relevant in this context:- 1.1.1 Non-Text Content
- 1.3.1 Info and Relationships
- 1.4.13 Content on Focus or Hover
- 2.4.3 Focus Order
- 2.4.7 Focus Visible
- 4.1.2 Name, Role, Value
More on Screen Readers
- Testing as Sighted with NVDA Screen Reader
- screen reader and Speech output - why is it so fast and sounds artificial?
- How does the Speech Output from blind Persons work?
- Which screen readers do blind persons use?
- Should Sighted test with screen readers?
- Talkback for Sighted
- Testing as a sighted person with iOS VoiceOver Screen Reader
- Tutorial for Screenreader Narrator for Sighted