Skip to main content

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.

Implementation Example:

<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:

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.

Understand SC 1.2.2: Captions (Prerecorded)

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.