Vanilla Breeze v0.7.4

Vanilla Breeze v0.7.4 released

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…

Read the release notes

track

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.

When to Use

  • 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

WebVTT Format

Track files use the WebVTT (Web Video Text Tracks) format.

Basic Structure

With Speaker Identification

With Sound Effects

Positioning and Styling

Chapter Markers

Attributes

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

Live Examples

Video with Multiple Tracks

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.

JavaScript API

Access track data programmatically for custom displays or metadata processing.

Custom Caption Display

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

CSS Reference

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:

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]).

↑