TExcelTAD
Home › HTML › HTML Media Accessibility

HTML Media Accessibility

Video and audio carry information that not everyone can perceive the same way. A deaf viewer cannot hear the dialogue, a blind listener cannot see what happens on screen, and someone on a quiet train may simply have their sound off. HTML gives you tools to make media usable for all of them — and they also help search engines and people who prefer reading.

Who needs what?

Alternative What it is Helps
Captions Text of the dialogue and important sounds ("[door slams]"), synced to the video Deaf and hard-of-hearing users, sound-off viewers
Subtitles Translation of the dialogue into another language Viewers who do not speak the language
Audio description Narration of important visual details Blind and low-vision users
Transcript The full text of the media on the page Everyone, including search engines
Keyboard-usable controls Play/pause etc. reachable with Tab and Enter Keyboard and switch users

The <track> element

Timed text is added with <track> inside <video> (or <audio>). The text itself lives in a WebVTT file (.vtt).

html
<video controls width="640">
  <source src="lecture.mp4" type="video/mp4">
  <track src="lecture-en.vtt" kind="captions" srclang="en" label="English" default>
  <track src="lecture-es.vtt" kind="subtitles" srclang="es" label="Español">
  <track src="lecture-desc.vtt" kind="descriptions" srclang="en" label="Audio description">
</video>
<track> attribute Meaning
src URL of the .vtt file
kind captions, subtitles, descriptions, chapters or metadata
srclang Language of the track, e.g. en
label Name shown in the player's caption menu
default Turn this track on automatically

The WebVTT format

A WebVTT file is plain text: a WEBVTT header, then numbered or unnamed cues, each with a time range and the text to show.

WEBVTT

00:00:00.000 --> 00:00:03.500
Welcome to the lecture on HTML.

00:00:03.500 --> 00:00:07.000
[keyboard clicking]
Let's open a new file.

Note: Track files must come from the same origin as the page (or be served with CORS headers). The playgrounds here are offline and sandboxed, so the examples below create cues with JavaScript instead of loading a .vtt file.

Building cues with JavaScript

The TextTrack API lets scripts create the same cues a .vtt file would contain. This example builds a caption track and lists its cues — the same data the player would display while the video plays.

html · try it yourself
<!DOCTYPE html>
<html>
<body>
  <video id="v" width="300" height="160" controls style="background:#222"></video>
  <ul id="list"></ul>
  <script>
    const video = document.getElementById('v');
    const list = document.getElementById('list');
    if (video.addTextTrack && window.VTTCue) {
      const track = video.addTextTrack('captions', 'English', 'en');
      track.mode = 'showing';
      track.addCue(new VTTCue(0, 3.5, 'Welcome to the lecture on HTML.'));
      track.addCue(new VTTCue(3.5, 7, '[keyboard clicking] Let\'s open a new file.'));
      for (const cue of track.cues) {
        const li = document.createElement('li');
        li.textContent = cue.startTime + 's – ' + cue.endTime + 's: ' + cue.text;
        list.appendChild(li);
      }
    } else {
      list.innerHTML = '<li>This browser does not support the TextTrack API.</li>';
    }
  </script>
</body>
</html>

Transcripts

A transcript is simply the media's text placed on the page — often in a collapsible <details> element so it does not take up space. It is the easiest accessibility win and works for audio-only content like podcasts, where captions do not apply.

html · try it yourself
<!DOCTYPE html>
<html>
<body>
  <h2>Episode 12: Learning HTML</h2>
  <audio controls>
    <source src="episode12.mp3" type="audio/mpeg">
  </audio>
  <details>
    <summary>Read the transcript</summary>
    <p><strong>Ana:</strong> Welcome back to the show! Today we're talking about HTML.</p>
    <p><strong>Ben:</strong> The first language every web developer meets.</p>
    <p><em>[upbeat music fades out]</em></p>
  </details>
</body>
</html>

Accessible custom controls

If you build your own play button, use a real <button> (it is focusable and works with Enter/Space automatically), give icon-only buttons an aria-label, and update it when the state changes.

html · try it yourself
<!DOCTYPE html>
<html>
<body>
  <button id="pp" aria-label="Play" aria-pressed="false" style="font-size:24px">▶</button>
  <p>Press Tab to focus the button, then Space to toggle it.</p>
  <p id="log" aria-live="polite"></p>
  <script>
    const pp = document.getElementById('pp');
    pp.addEventListener('click', function () {
      const playing = pp.getAttribute('aria-pressed') === 'true';
      pp.setAttribute('aria-pressed', String(!playing));
      pp.setAttribute('aria-label', playing ? 'Play' : 'Pause');
      pp.textContent = playing ? '▶' : '⏸';
      document.getElementById('log').textContent = playing ? 'Paused' : 'Playing';
    });
  </script>
</body>
</html>

aria-live="polite" tells screen readers to announce the status text when it changes.

Checklist

  • Provide captions for every video with speech or meaningful sound.
  • Provide a transcript for audio-only content.
  • Describe important visuals (with narration, a descriptions track, or text on the page).
  • Never autoplay sound; let users pause anything that moves for more than five seconds.
  • Make every control reachable and usable with the keyboard.
  • Avoid flashing content (more than three flashes per second can trigger seizures).

Tip: Auto-generated captions are a good starting point, but always proofread them — machine transcription regularly gets names and technical terms wrong.

Test yourself

Which element adds captions or subtitles to a <video>?

  1. <caption>
  2. <track>
  3. <subtitle>
  4. <source>

How do captions differ from subtitles?

  1. They are the same thing
  2. Captions include important sounds and are aimed at people who cannot hear; subtitles translate dialogue
  3. Subtitles are only for audio
  4. Captions are images

What is the best accessible alternative for an audio-only podcast?

  1. A <track kind="captions">
  2. A transcript on the page
  3. A poster image
  4. Turning on loop