Start with plain HTML
A useful transcript does not need media or JavaScript. Clear, semantic HTML is enough.
Transcript — Building accessible interfaces
Host: If you are building a transcript, where do you start?
Guest: With clear content and the right native HTML for its structure.
Host: And if JavaScript fails or never loads?
Guest: Nothing important disappears. The complete transcript is still there to read and copy.
Add sync to audio
Press play to follow the current cue, or choose any cue to jump to that
point. The current cue gets aria-current="time", and focus
stays on the cue you chose.
Transcript — Local narration
Use the same setup with video
The transcript can connect to a native <video> in the same
way. This example uses the same narration but groups it into four
longer cues.
Transcript — Video version
Build your own synced transcript
Start with native media controls and a complete HTML transcript. Add timestamps to the cue buttons, connect the transcript to the media, and initialize it once. If JavaScript does not load, the transcript is still available.
HTML
<audio id="episode-audio" controls>
<source src="/media/episode.m4a" type="audio/mp4" />
</audio>
<section
class="a11y-transcript"
data-a11y-transcript
data-media="#episode-audio"
data-sync
aria-labelledby="episode-transcript-title"
>
<!-- data-media connects this transcript to the native audio element. -->
<h2 id="episode-transcript-title" class="a11y-transcript__title">
Episode transcript
</h2>
<ol class="a11y-transcript__list">
<li class="a11y-transcript__item">
<button class="a11y-transcript__cue" type="button" data-start="0" data-end="8">
<span class="a11y-transcript__time">00:00</span>
Welcome to the episode.
</button>
</li>
</ol>
</section>
JavaScript
import { createA11yTranscript } from "a11y-transcript";
import "a11y-transcript/styles.css";
const root = document.querySelector("[data-a11y-transcript]");
if (root instanceof HTMLElement) {
// The source HTML remains useful when JavaScript is unavailable.
createA11yTranscript(root);
}
Try the other demos
- Compare cue interactivity settings to see which cues enter the tab order.
- Try every optional add-on together in one longer transcript.
- Break a few setups on purpose, then see how they fail and recover.
Things worth testing
- Reload with JavaScript disabled. Every transcript should still be readable.
- Use Enter and Space on a cue. Playback should seek without moving focus.
- Inspect the current cue during playback. It should have
aria-current="time". - Listen with a screen reader. Automatic cue changes should not be announced.
- Test at 200% zoom, 320 CSS pixels, and in forced-colors mode.