Visually Hidden

시각적으로 숨기기

A CSS technique that hides an element visually while a screen reader still reads it — completely different from display: none.

Also known as: .sr-onlyscreen-reader-only text
···
html
<div class="stage">
  <div class="pane">
    <div class="tag">display: none</div>
    <button class="sb"><span class="glass"></span></button>
    <div class="eye ok">눈: 안 보임</div>
    <div class="ear bad">SR: (없음)</div>
  </div>
  <div class="pane">
    <div class="tag">visibility: hidden</div>
    <button class="sb"><span class="glass"></span><span class="ghost">Search</span></button>
    <div class="eye ok">눈: 안 보임</div>
    <div class="ear bad">SR: (없음)</div>
  </div>
  <div class="pane">
    <div class="tag">.sr-only</div>
    <button class="sb"><span class="glass"></span></button>
    <div class="eye ok">눈: 안 보임</div>
    <div class="ear good">SR: "Search"</div>
  </div>
</div>
css
.stage{width:96%;height:90%;display:flex;gap:3%}
.pane{position:relative;flex:1;border-radius:12px;border:1px solid var(--line);background:var(--surface);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8%;padding:16% 4% 6%}
.tag{position:absolute;top:8px;left:8px;right:8px;font:700 9px/1.2 ui-monospace,monospace;color:var(--muted);text-align:center}
.sb{width:30%;aspect-ratio:1;border-radius:9px;border:1px solid var(--line);background:var(--bg);display:grid;place-items:center;position:relative}
.glass{width:44%;height:44%;border:2px solid var(--fg);border-radius:50%;position:relative}
.glass::after{content:'';position:absolute;width:6px;height:2px;background:var(--fg);right:-5px;bottom:-1px;transform:rotate(45deg)}
.ghost{position:absolute;visibility:hidden;font-size:8px}
.eye,.ear{font:700 9.5px/1.2 ui-monospace,monospace;text-align:center}
.eye.ok{color:var(--muted)}
.ear.bad{color:var(--accent-2)}
.ear.good{color:var(--accent-3)}

`display: none` and `visibility: hidden` also remove an element from the accessibility tree, so a screen reader never even knows it existed. But there's often text that's visually redundant yet essential for a screen reader — the label behind an icon-only button, extra context on a table's repeated header.

The `.sr-only` class (often called `.visually-hidden`) shrinks an element to 1px×1px and combines `overflow: hidden`, `clip-path`, and `position: absolute` so it vanishes visually without ever touching `display` or `visibility` — leaving it fully present in the accessibility tree. `opacity: 0` or `width: 0` alone aren't enough; they can still affect layout or drop out of the tree in some browsers.

The demo hides a search button's label three different ways and contrasts what's left for the eye versus what's left for the ear.

When to use

Use it for text a screen is fine without but an ear needs: icon button labels, skip links, extra form context. For content you're temporarily hiding and will show again — an accordion panel, a tab — use the hidden attribute or display: none instead; that content really should disappear entirely.