Skip to main content
  1. All Posts/

Hidden content – Accessibility Guidelines

Accessibility 18F GSA
Table of Contents

Hiding content is very useful for accessibility. We can hide things visually and only display it to screen reader users, we can hide content from screen reader users and only show it visually, or we can hide content from both.

Techniques>

Techniques #

Aria hidden>

Aria hidden #

aria-hidden should be used in combination with these techniques. If we want to hide something from just the screen reader, you can mark it as aria-hidden=‘true’.

Items with aria-hidden=‘true’ are always ignored by the screen reader. This is useful for:

  • Collapsing Menus
  • Repetitive information
  • Off screen content

If an element has multiple states, its visibility should be tracked with aria-hidden true/false. An element with aria-hidden=‘false’ is treated by the screen reader as if it didn’t have the aria-hidden attribute and is read or not read based on other factors, such as CSS.

CSS>

CSS #

CSS can be used to hide content and allow it to still be used with the screen reader.

Using this we can:

  • Provide additional details about a form element
    • Hidden labels
    • Error details
  • Provide context to page elements
  • Add additional instructions for navigation

We can also use CSS to hide content visually and from screen readers.

{ display: none; }

This will hide completely and is the same as <div aria-hidden=‘true’ hidden>content</div> Note that aria-hidden=‘true’ should be used for additional compatibility.

display: none; and hidden can be used for:

  • Collapsing menus
  • Repetitive information
  • Off-screen content