Skip to content

Instantly share code, notes, and snippets.

@davidhund
Last active August 30, 2024 17:03
Show Gist options
  • Save davidhund/fddb4798c3c3a5d11f5092372818cbef to your computer and use it in GitHub Desktop.
Save davidhund/fddb4798c3c3a5d11f5092372818cbef to your computer and use it in GitHub Desktop.
Hide visually, show for AT
/**
* = Visually Hide text
*
* Text remains accessible to AT such as Screen Readers
* Updated version:
* Taken from http://hugogiraudel.com/2016/10/13/css-hide-and-seek/
*
* ------------------------------------------------------------------------- */
.visually-hidden {
border: 0 !important;
clip: rect(1px, 1px, 1px, 1px) !important;
clip-path: inset(50%) !important;
height: 1px !important;
overflow: hidden !important;
padding: 0 !important;
position: absolute !important;
width: 1px !important;
white-space: nowrap !important;
}
/* Remain focusable, e.g. when using skip-links */
.visually-hidden--focusable:focus,
.visually-hidden--focusable:active {
clip-path: none !important;
height: auto !important;
overflow: visible !important;
position: static !important;
width: auto !important;
white-space: normal !important;
}