Skip to content

Instantly share code, notes, and snippets.

@mvsde
Last active January 7, 2020 15:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mvsde/f74ad9f5e43994478060e5a559f21922 to your computer and use it in GitHub Desktop.
Save mvsde/f74ad9f5e43994478060e5a559f21922 to your computer and use it in GitHub Desktop.
Hide element visually but keep it in accessibility tree
/**
* Visually hides elements but keeps them accessible for screen readers and
* keyboard users.
*
* Source:
* https://allyjs.io/tutorials/hiding-elements.html#2017-edition-of-visuallyhidden
*/
.sr-only:not(:focus):not(:active) {
position: absolute;
width: 1px;
height: 1px;
margin: -1px;
border: 0;
padding: 0;
white-space: nowrap;
clip-path: inset(100%);
clip: rect(0 0 0 0);
overflow: hidden;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment