What are the different ways to visually hide content (and make it available only for screen readers)?

Technology CommunityCategory: CSSWhat are the different ways to visually hide content (and make it available only for screen readers)?
VietMX Staff asked 3 years ago

These techniques are related to accessibility (a11y).

  • visibility: hidden. However the element is still in the flow of the page, and still takes up space.
  • width: 0; height: 0. Make the element not take up any space on the screen at all, resulting in not showing it.
  • position; absolute; left: -99999px. Position it outside of the screen.
  • text-indent: -9999px. This only works on text within the block elements.
  • .sr-only class for Bootstrap