CSS Snippet

CSS Utility Tricks: Invisible Text and Filters

Difficulty: Easy

Two utility recipes that come up over and over: hiding content correctly (visually-hidden but readable to screen readers, plus a decision matrix for the four ways to make something disappear) and using `filter` for cheap visual effects like blur, grayscale, and drop-shadow. Both are short on their own but easy to get wrong, so they live together as a quick reference.

Code Snippets
/

CSS Utility Tricks: Invisible Text and Filters

CSS Utility Tricks: Invisible Text and Filters

Two utility recipes that come up over and over: hiding content correctly (visually-hidden but readable to screen readers, plus a decision matrix for the four ways to make something disappear) and using `filter` for cheap visual effects like blur, grayscale, and drop-shadow. Both are short on their own but easy to get wrong, so they live together as a quick reference.

CSS
Easy
3 snippets
css-display
css-filters
accessibility

471 views

11

The visually-hidden technique is the standard pattern for making content invisible without removing it from the accessibility tree. Crucially, it uses position: absolute, a 1x1 size, and clip: rect(0,0,0,0) rather than display: none, because display: none removes the element entirely; screen readers will not see it. Use this every time an icon-only button needs a label, or when you want extra context (like "opens in a new tab") that a sighted user does not need. The focusable variant is for skip-links: hidden by default, but visible when a keyboard user tabs to them, which is a baseline accessibility requirement.