Welcome to Vanilla Breeze
This bell pulls live notifications from /go/notify/messages — the same contract documented at /docs/concepts/service-contracts/. Static articles like this one are the no-JS / no-backend fallback.
This bell pulls live notifications from /go/notify/messages — the same contract documented at /docs/concepts/service-contracts/. Static articles like this one are the no-JS / no-backend fallback.
The track element provides timed text tracks for video and audio elements, enabling captions, subtitles, descriptions, and chapter markers.
The <track> element specifies timed text tracks (in WebVTT format) for <video> and <audio> elements. These tracks provide captions for deaf users, subtitles for foreign languages, audio descriptions for blind users, and chapter navigation.
Tracks are essential for accessibility and are required by many accessibility standards (WCAG) for video content with audio.
| Kind | Purpose | Display |
|---|---|---|
captions |
Dialogue + sound effects for deaf/hard-of-hearing | Shown over video |
subtitles |
Translation of spoken dialogue | Shown over video |
descriptions |
Audio descriptions of visual content | Synthesized speech or separate audio |
chapters |
Chapter titles for navigation | In browser UI/controls |
metadata |
Machine-readable data | Not displayed (JavaScript access) |
Designed for deaf and hard-of-hearing users. Include:
Designed for users who can hear but don't understand the spoken language. Include:
<video controls> <source src="movie.mp4" type="video/mp4" /> <!-- Captions for deaf/hard-of-hearing --> <track kind="captions" src="captions-en.vtt" srclang="en" label="English captions" default /> <!-- Subtitles for non-English speakers --> <track kind="subtitles" src="subtitles-es.vtt" srclang="es" label="Spanish" /> <track kind="subtitles" src="subtitles-fr.vtt" srclang="fr" label="French" /></video>
Track files use the WebVTT (Web Video Text Tracks) format.
WEBVTT 00:00:01.000 --> 00:00:04.000Hello, and welcome to this tutorial. 00:00:05.000 --> 00:00:08.500Today we'll learn about HTML video captions. 00:00:09.000 --> 00:00:12.000Let's get started!
WEBVTT 00:00:01.000 --> 00:00:03.500<v Host>Welcome to the show!</v> 00:00:04.000 --> 00:00:06.500<v Guest>Thanks for having me.</v>
WEBVTT 00:00:01.000 --> 00:00:03.000[suspenseful music] 00:00:03.500 --> 00:00:05.000[door creaks open] 00:00:05.500 --> 00:00:08.000Who's there?
WEBVTT 00:00:01.000 --> 00:00:04.000 line:90% position:50% align:centerCentered at bottom 00:00:05.000 --> 00:00:08.000 line:10% position:10% align:leftTop left corner
WEBVTT chapter-100:00:00.000 --> 00:02:30.000Introduction chapter-200:02:30.000 --> 00:08:15.000Getting Started chapter-300:08:15.000 --> 00:15:00.000Advanced Topics chapter-400:15:00.000 --> 00:20:00.000Conclusion
| Attribute | Description |
|---|---|
src |
URL of the track file (.vtt) |
kind |
captions, subtitles, descriptions, chapters, or metadata |
srclang |
Language of the track (BCP 47 language tag) |
label |
User-readable title shown in track selection |
default |
Enable this track by default |
<track kind="captions" src="captions.vtt" srclang="en" label="English" default />
<video controls> <source src="presentation.mp4" type="video/mp4" /> <!-- Captions --> <track kind="captions" src="captions-en.vtt" srclang="en" label="English captions" default /> <!-- Subtitles in other languages --> <track kind="subtitles" src="subtitles-es.vtt" srclang="es" label="Espanol" /> <track kind="subtitles" src="subtitles-zh.vtt" srclang="zh" label="Chinese" /> <!-- Audio descriptions for blind users --> <track kind="descriptions" src="descriptions-en.vtt" srclang="en" label="Audio descriptions" /> <!-- Chapter markers --> <track kind="chapters" src="chapters-en.vtt" srclang="en" label="Chapters" /></video>
Tracks can also be used with audio elements, though browser support varies.
<audio controls> <source src="podcast.mp3" type="audio/mpeg" /> <track kind="captions" src="podcast-captions.vtt" srclang="en" label="Transcript" default /></audio>
Access track data programmatically for custom displays or metadata processing.
const video = document.querySelector('video');const track = video.textTracks[0]; // Listen for cue changestrack.oncuechange = function() { const activeCues = track.activeCues; if (activeCues.length > 0) { console.log('Current caption:', activeCues[0].text); }}; // Show/hide tracks programmaticallytrack.mode = 'showing'; // Show captionstrack.mode = 'hidden'; // Load but don't displaytrack.mode = 'disabled'; // Don't load/code-block <h3>Custom Caption Display</h3> <code-block language="html" show-lines label="Custom caption display" data-escape><video id="myVideo" controls> <source src="video.mp4" type="video/mp4" /> <track kind="captions" src="captions.vtt" srclang="en" default /></video><div id="custom-captions"></div> <script>const video = document.getElementById('myVideo');const captionDisplay = document.getElementById('custom-captions'); video.textTracks[0].mode = 'hidden'; video.textTracks[0].oncuechange = function() { const cue = this.activeCues[0]; captionDisplay.textContent = cue ? cue.text : '';};</script>
Web Content Accessibility Guidelines require captions and audio descriptions:
| Criterion | Level | Requirement |
|---|---|---|
| 1.2.2 Captions (Prerecorded) | A | Captions for all prerecorded audio in video |
| 1.2.3 Audio Description or Media Alternative | A | Audio description or text alternative for video |
| 1.2.4 Captions (Live) | AA | Captions for live audio in video |
| 1.2.5 Audio Description (Prerecorded) | AA | Audio description for prerecorded video |
kind="captions" for deaf/hard-of-hearing userskind="subtitles" for translations only<video> - Video player that accepts track elements<audio> - Audio player that accepts track elements<audio-player> - Web component with custom controls that supports text tracks<source> - Media sources for video/audio<details> - Useful for building chapter navigation UI from chapter trackssrclang attributeThe <track> element is not rendered directly. Caption styling is controlled via the ::cue pseudo-element.
/* Style video captions */video::cue { background: rgba(0, 0, 0, 0.8); color: white; font-family: system-ui, sans-serif; font-size: 1rem;} /* Style specific voices */video::cue(v[voice="Host"]) { color: yellow;} /* Hide track element (precautionary) */track { display: none;}