Skip to the page

The cascade and the box · core

Hiding things: display, visibility, opacity and accessibility

display: none removes the element from layout and the accessibility tree, visibility: hidden keeps its space but hides it from everyone, opacity: 0 keeps it clickable and readable by screen readers, and a visually-hidden class hides it only visually.

The notes

What you must know

  • display: none — no space, not focusable, not announced.
  • visibility: hidden — keeps space, not focusable or announced; can be animated with a delay.
  • opacity: 0 — invisible but still takes space, receives clicks and is announced.
  • hidden attribute = display: none by default; aria-hidden='true' hides from screen readers only.
  • Visually hidden (sr-only) pattern for text only screen readers should read.

The red pen

Common traps: mistake → fix

  • Mistake: "opacity: 0 is the same as hidden"

    Fix: the element can still be clicked and read aloud.

Easy to hard

Questions interviewers ask, easy to hard

  1. Compare display none, visibility hidden and opacity 0.
  2. How do you hide something visually but keep it for screen readers?

Explain it out loud

Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.

Practise by voice

Your first interview is free

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview