Skip to main content

The <track> Element

As defined in the HTML Living Standard, the <track> element allows authors to specify explicit external timed text tracks for <audio> and <video> elements. It is a void element.

Visual Concept:

🎬
[Narrator]: Semantic HTML is key to access.

(Simulation of a caption track being rendered over a video.)

<video src="movie.mp4" controls> <track kind="captions" src="subs_en.vtt" srclang="en" label="English" default> </video> View HTML Living Standard: The track element

The kind Attribute

The kind attribute defines the purpose of the text track. Choosing the correct value is essential for accessibility:

WCAG Requirement: Captions

Success Criterion 1.2.2 (Level A): Captions are provided for all prerecorded audio content in synchronized media.

Using <track kind="captions"> with a valid WebVTT (.vtt) file is the standard method for meeting this requirement. It ensures that the text remains synchronized with the audio and that users can toggle the captions on or off using native browser controls.

Understand SC 1.2.2: Captions

Technical Requirements

<!-- Multiple language support --> <video controls> <source src="video.webm" type="video/webm"> <track kind="subtitles" src="en.vtt" srclang="en" label="English"> <track kind="subtitles" src="fr.vtt" srclang="fr" label="Français"> </video>

Best Practices

A11y Tip: User Styling

Native <track> elements allow users to customize the appearance of captions (font size, background color, opacity) through their operating system or browser settings. This is a significant accessibility advantage over "burned-in" or hard-coded captions.