The <track> Element
As defined in the HTML Living Standard, the <track> element is used as a child of <audio> or <video> to specify timed text tracks, such as captions, subtitles, or descriptions. It is a void element.
<track
kind="captions"
src="captions.vtt"
srclang="en"
label="English"
default>
View HTML Living Standard: The track element
The Role of the kind Attribute
The kind attribute determines how the browser treats the text track:
- captions: For deaf or hard-of-hearing users. Includes dialogue and descriptions of non-speech sounds (e.g., "[Dramatic Music Plays]").
- subtitles: For users who can hear but don't understand the language. Only includes dialogue.
- descriptions: Textual descriptions of the visual action for blind or low-vision users.
- chapters: Used to divide the media into navigable segments.
WCAG Requirement: Captions (Prerecorded)
Success Criterion 1.2.2 (Level A): Captions are provided for all prerecorded audio content in synchronized media.
The <track> element is the primary mechanism for achieving this. Without a valid captions track, a video is fundamentally inaccessible to a significant portion of the population.
Technical Requirements: WebVTT
The src attribute must point to a file in the WebVTT (.vtt) format. This is a plain-text format that allows for precise timing and styling of text overlays.
A11y Tip: The 'default' Attribute
Use the default attribute to specify which track should be enabled by default when the video starts. This ensures that accessibility features are "on" by default, reducing the friction for users who need them.