0.7.4 gives the Ambient pack weather. A page names one feed URL on its own site, and the pack sets data-weather from it, uses its sunrise and sunset for dawn and dusk, and never shows a stale observation. Helpers for producing the feed from Open-Meteo are included. Ambient p…
The track element provides timed text tracks for video and audio elements, enabling captions, subtitles, descriptions, and chapter markers.
Description
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, text descriptions of visual content, and chapter markers.
Tracks are essential for accessibility and are required by many accessibility standards (WCAG) for video content with audio.
The demo below loads two local WebVTT files: a captions track shown over the video with VB's ::cue defaults, and a chapters track rendered as a clickable list by data-chapter-list.
Captions - Transcription of dialogue plus descriptions of important sounds
Subtitles - Translation of dialogue into another language
Descriptions - Text descriptions of visual content, for script or a player to voice
Chapters - Navigation markers for longer videos
Metadata - Machine-readable data synchronized with media
Track Kinds
Kind
Purpose
Display
captions
Dialogue + sound effects for deaf/hard-of-hearing
Shown over video
subtitles
Translation of spoken dialogue
Shown over video
descriptions
Text descriptions of visual content
Not shown or spoken by mainstream browsers. Script must read the cues (cuechange) and voice them, for example with speechSynthesis or an aria-live region.
chapters
Chapter titles for navigation
Not shown by mainstream browsers. Render them with script; in VB, add data-chapter-list to the track.
metadata
Machine-readable data
Not displayed (JavaScript access)
Captions vs Subtitles
Captions
Designed for deaf and hard-of-hearing users. Include:
All spoken dialogue
Speaker identification when not obvious
Sound effects: [door slams], [phone rings]
Music descriptions: [upbeat jazz music]
Non-verbal sounds: [sighs], [laughs]
Subtitles
Designed for users who can hear but don't understand the spoken language. Include:
Translation of spoken dialogue
Assume user can hear non-speech audio
Captions vs subtitles
123456789101112131415161718192021222324
<videocontrols><sourcesrc="movie.mp4"type="video/mp4" /><!-- Captions for deaf/hard-of-hearing --><trackkind="captions"src="captions-en.vtt"srclang="en"label="English captions"default /><!-- Subtitles for non-English speakers --><trackkind="subtitles"src="subtitles-es.vtt"srclang="es"label="Spanish" /><trackkind="subtitles"src="subtitles-fr.vtt"srclang="fr"label="French" /></video>
WebVTT Format
Track files use the WebVTT (Web Video Text Tracks) format.
Basic Structure
WebVTT basic format
12345678910
WEBVTT00: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!
With Speaker Identification
WebVTT with speaker identification
1234567
WEBVTT00: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>
<videocontrols><sourcesrc="presentation.mp4"type="video/mp4" /><!-- Captions --><trackkind="captions"src="captions-en.vtt"srclang="en"label="English captions"default /><!-- Subtitles in other languages --><trackkind="subtitles"src="subtitles-es.vtt"srclang="es"label="Espanol" /><trackkind="subtitles"src="subtitles-zh.vtt"srclang="zh"label="Chinese" /><!-- Audio descriptions for blind users --><trackkind="descriptions"src="descriptions-en.vtt"srclang="en"label="Audio descriptions" /><!-- Chapter markers --><trackkind="chapters"src="chapters-en.vtt"srclang="en"label="Chapters" /></video>
Audio with a Transcript Track
<audio> accepts <track> children and exposes them through audio.textTracks, but browsers never draw cues for audio: there is no video area to draw them on. Read the cues with script, or better, publish a full transcript next to the player.
<videoid="myVideo"controls><sourcesrc="video.mp4"type="video/mp4" /><trackkind="captions"src="captions.vtt"srclang="en"default /></video><pid="custom-captions"aria-live="off"></p><script>const video = document.getElementById('myVideo');const captionDisplay = document.getElementById('custom-captions');video.textTracks[0].mode = 'hidden'; // load cues, but do not draw themvideo.textTracks[0].oncuechange = function () {const cue = this.activeCues[0];// cue.text keeps WebVTT markup such as <v Host>; getCueAsHTML() parses it// into safe DOM (spans, no script), and textContent drops the tags. captionDisplay.replaceChildren(cue ? cue.getCueAsHTML() : '');};</script>
Captions are visual, so the display uses aria-live="off": screen reader users hear the soundtrack itself, and announcing every cue would talk over it.
Accessibility
WCAG Requirements
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
Best Practices
Always provide captions for videos with speech
Use kind="captions" for deaf/hard-of-hearing users
Use kind="subtitles" for translations only
Include sound effects and speaker identification in captions
Ensure caption timing matches audio accurately
Provide a text transcript as an additional option
Test captions with actual users
Caption Quality
Synchronize captions to within 1 second of audio
Don't exceed 2 lines per caption
Keep captions on screen long enough to read (minimum 1 second)
Use standard punctuation and grammar
Indicate speaker changes clearly
Related
<video> - Video player that accepts track elements
<audio> - Audio player that accepts track elements
<video-player> - Custom video controls with a captions toggle that follows the default captions track
The <track> element is not rendered. Cues are styled with the ::cue pseudo-element, which accepts only a few properties: color, background, font, text-shadow, outline, line-height, opacity, text-decoration and white-space. VB ships a token-based default in native-elements/video/styles.css:
VB ::cue defaults
1234567891011
video::cue {color: var(--cue-text, var(--color-gray-50));background-color: var(--cue-bg, oklch(from var(--color-gray-950) l c h / 0.85));font-family: var(--cue-font, var(--font-sans));line-height: var(--line-height-normal, 1.5);}/* Style a speaker: matches <v Host> in the WebVTT file */video::cue(v[voice="Host"]) {font-style: italic;}
Custom property
Default
--cue-text
var(--color-gray-50)
--cue-bg
--color-gray-950 at 85% opacity
--cue-font
var(--font-sans)
User preferences and forced colors
Caption settings in the operating system (macOS and iOS Accessibility > Captions, Windows closed-caption settings, Android caption preferences) override author ::cue styles in most browsers, and forced-colors mode repaints cues in system colours. That is intended: viewers who set a caption size or colour need it to win. Keep author cue styles modest, do not use !important, and never encode meaning in cue colour alone (use speaker names or brackets such as [door slams]).