Accessible hidden content | The A11y Project

Great write up on the current best practices around hiding elements keeping all users in mind:

.visually-hidden {
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

Or if you need to unhide when focused (better for keyboard users etc.):

.visually-hidden:not(:focus):not(:active) {
  /* ... */
}

Alternatively, need to hide an element from non-visual users (screen readers, smart speakers, reading mode), use aria-hidden: true and then if you also need to hide visually:

.my-component[aria-hidden="true"] {
  display: none;
}

Or use the HTML5 hidden attribute.

Explore Other Notes

Older âž¡

State of frontend 2020

Some interesting results from the latest Software House frontend survey. Surprised to see that over a third of respondents reckoned CSS-in-JS would be a "fad" and gone in three years; personally […]
  • Great write up on the current best practices around hiding elements keeping all users in […]
  • Murray Adcock.
Journal permalink

Made By Me, But Made Possible By:

CMS:

Build: Gatsby

Deployment: GitHub

Hosting: Netlify

Connect With Me:

Twitter Twitter

Instagram Instragram

500px 500px

GitHub GitHub

Keep Up To Date:

All Posts RSS feed.

Articles RSS feed.

Journal RSS feed.

Notes RSS feed.