Community Question Bundle

The CSS Accessibility Tricks I Keep Using

Five accessibility moves I have committed to muscle memory: the visually-hidden snippet, skip links, focus-visible rings, reduced-motion, and a CSS variable trick that catches contrast bugs at build time.

The CSS Accessibility Tricks I Keep Using

Five accessibility moves I have committed to muscle memory: the visually-hidden snippet, skip links, focus-visible rings, reduced-motion, and a CSS variable trick that catches contrast bugs at build time.

Question Bundle
CSS
5 questions
accessibility
css-display
css-pseudo-classes
interview-prep
arjunrivera

By @arjunrivera

November 21, 2025

·

Updated May 18, 2026

730 views

6

4.0 (10)

I need a class that visually hides content but keeps it readable by screen readers. The naive display: none hides it from everyone. Write the modern snippet I drop into every project, and explain why display: none and visibility: hidden are both wrong.

What I want to see

The .sr-only (or .visually-hidden) pattern: 1px box, clipped, absolutely positioned, no border, overflow hidden, no whitespace. Both display: none and visibility: hidden remove the element from the accessibility tree.