v6.0.0-beta.5
  • Home
  • Tokens
  • Layout
  • Utilities
    • Click Area
    • Container
    • Counted
    • Dimensions
    • Hover Group
    • Indexed
    • Margin
    • No Print
    • Typography
    • Visually Hidden
    • Z-Index
  • Guides
  • home
  • /
  • utilities
  • /
  • Visually Hidden
Source

Visually Hidden

The Visually Hidden utilities hide elements visually while keeping them accessible to screen readers and other assistive technologies. These utilities are essential for creating accessible interfaces where you need to provide information for screen reader users without affecting the visual design.

Usage

Apply .visually-hidden or .sr-only to elements that should be available to assistive technologies but hidden from visual users. Use the focusable variants for elements that should become visible when they receive keyboard focus, such as skip links.

<h1>Page Title</h1>
<a href="#main-content" class="visually-hidden-focusable">
  Skip to main content
</a>

<button>
  <span class="visually-hidden">Close dialog</span>
  <svg aria-hidden="true"><!-- close icon --></svg>
</button>

<div class="sr-only">Screen reader only instructions</div>

The utilities ensure that hidden content remains in the accessibility tree while being completely invisible to sighted users, maintaining proper focus order and keyboard navigation.

Class Patterns

Pattern Description
.visually-hidden Hides element visually but keeps it accessible to screen readers
.sr-only Alternative name for visually-hidden (screen reader only)
.visually-hidden-focusable Shows hidden element when it receives focus (for skip links)
.sr-only-focusable Alternative name for visually-hidden-focusable
← utilities: Typography utilities: Z-Index →
© Crinkles.
Powered by: 11ty & Feo.css | Github