대체 텍스트

Alt Text

이미지 대신 스크린 리더가 읽어줄 텍스트. 의미 있는 이미지엔 설명을, 장식용 이미지엔 빈 alt를 줍니다.

다른 이름: alt attribute
···
html
<div class="stage" id="stage">
  <div class="pane">
    <div class="ph"></div>
    <div class="tag ok">Good</div>
    <div class="say" id="s1"></div>
  </div>
  <div class="pane">
    <div class="ph"></div>
    <div class="tag bad">Bad</div>
    <div class="say" id="s2"></div>
  </div>
  <div class="pane">
    <div class="ph deco"></div>
    <div class="tag deco">Decorative</div>
    <div class="say" id="s3"></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;padding:8% 4% 6%;gap:7%}
.ph{width:100%;flex:1;border-radius:8px;background:linear-gradient(135deg,var(--accent),var(--accent-3));opacity:.85}
.ph.deco{opacity:.3}
.tag{font:700 10px/1 ui-monospace,monospace;color:var(--muted)}
.tag.ok{color:var(--accent-3)}
.tag.bad{color:var(--accent-2)}
.say{width:100%;min-height:26px;font:9.5px/1.3 ui-monospace,monospace;color:var(--fg);text-align:center;opacity:0;transition:opacity .3s ease}
.say.on{opacity:1}
.say.muted{color:var(--muted);font-style:italic}
js
const items = [
  { id: 's1', text: 'golden retriever, beach', muted: false },
  { id: 's2', text: 'IMG_2043.jpg', muted: false },
  { id: 's3', text: '(skipped)', muted: true },
];
function run() {
  items.forEach(function (it, i) {
    setTimeout(function () {
      const el = document.getElementById(it.id);
      el.textContent = it.text;
      if (it.muted) el.classList.add('muted');
      el.classList.add('on');
    }, i * 600);
  });
  setTimeout(function () {
    items.forEach(function (it) { document.getElementById(it.id).classList.remove('on'); });
  }, 3600);
}
run();
setInterval(run, 4400);

`<img alt="...">`는 이미지가 로드되지 않을 때의 대체 문구가 아니라, 스크린 리더가 그 이미지 **대신** 읽는 텍스트입니다. 좋은 alt는 이미지가 전달하는 정보나 기능을 문맥에 맞게 설명합니다. 파일명을 그대로 쓰거나(`IMG_2043.jpg`) "이미지"라고만 쓰는 것은 정보가 전혀 없어서 없는 것과 다를 바 없습니다.

순수하게 장식용인 이미지(배경 패턴, 아이콘 옆의 중복 그림)는 `alt=""`(빈 문자열)를 줘서 스크린 리더가 아예 건너뛰게 만듭니다. `alt` 속성 자체를 생략하면 오히려 일부 스크린 리더가 파일 경로를 읽어버리는 더 나쁜 결과가 나올 수 있습니다.

데모는 같은 사진을 세 가지로 처리했을 때 스크린 리더가 실제로 뭐라고 읽는지 보여줍니다 — 좋은 설명, 의미 없는 텍스트, 그리고 건너뛰기(침묵)입니다.

언제 쓰나

이미지를 넣을 때마다 "이 이미지가 없으면 사용자가 뭘 놓치는가"를 자문하세요. 답이 없다면 빈 alt, 답이 있다면 그 답을 그대로 alt에 쓰면 됩니다.