An array of techniques for hiding content from standard browsers, screen readers, and other assistive devices. Focus on accessibility and CSS best practices. Subject to change. Questions or concerns? Please leave a comment on the original blog post.
User Agent String: Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
display: none
Toggle Test Case #1 Currently: Enabled
display: none
is applied to an element. The element is hidden entirely, both visually and from assistive technologies.visibility: hidden
Toggle Test Case #2 Currently: Enabled
visibility: hidden
is applied to an element. The element is turned invible in a browser, but retains its physical space. The element and its contents are hidden from assistive technologies.opacity: 0
Toggle Test Case #3 Currently: Enabled
opacity: 0
is applied to an element. The element is turned invisible in a browser but (usually) retains its physical space. Its contents are not hidden from assistive technologies.Toggle Test Case #4 Currently: Enabled
An element is given a combination of CSS attributes that attempt to hide it visually but keep it accessible to screen readers. CSS developed by Jon Snook and Yahoo.
Applicable CSS:
.hide-visually { position: absolute !important; height: 1px; width: 1px; overflow: hidden; clip: rect(1px 1px 1px 1px); clip: rect(1px, 1px, 1px, 1px); }
aria-hidden
Toggle Test Case #5 Currently: Enabled
aria-hidden="true"
. More information from The Paciello Group.Toggle Test Case #6 Currently: Enabled
An element is given a combination of CSS attributes that attempt to hide the text inside the element while keeping the element itself visible. Most useful for image replacement techniques, or for providing alternate descriptions for other inaccessible media. The text should be accessible to screen readers.
Applicable CSS:
.hide-text { /* newer */ text-indent: -300%; white-space: nowrap; overflow: hidden; }
Note the use of the negative value on the percentage. The original method used a positive percentage that causes the text to appear if a nested anchor tag is focused on via tabbing.
More about image replacement stuff at CSS-101.org.