Bootstrap – Visually Hidden


Bootstrap – Visually hidden



”;


This chapter discusses about classes provided by Bootstrap to visually hide any element, such as .visually-hidden and .visually-hidden-focusable.

  • The .visually-hidden class in Bootstrap 5 is used to visually hide an element while keeping it accessible to screen readers and other assistive technologies.

  • The .visually-hidden-focusable class is used to visually hide an element by default, but to display it when it’s focused, for example, on using a keyboard.

  • The .visually-hidden-focusable class can also be used within a container :focus-within. The container will be displayed when any child element of the container receives focus.

Test focusability: Use keyboard navigation to test the focusability of elements. Press the Tab key to navigate through the focusable elements and Shift + Tab to move backward.

Let”s see an example on the usage of the classes .visually-hidden and .visually-hidden-focusable: