HTML audio / video track - how to use <track> tag

The HTML <track> tag is used to define the track for the <audio> and <video> tags. The <track> tag can specify subtitles and caption that should be visible when the audio or video is playing.

Attributes

The track tag supports the global and event attributes.

default
Defines the default track to be played
kind
Defines the type of track - captions, chapters, description, metadata or subtitles
label
Defines the title of the track
src
Defines the URL of the track
srclang
Defines the language of the track when kind is subtitles

Examples:

<video width="400" height="200" controls> <source src="file.mp4" type="video/mp4"> <source src="file.ogg" type="video/ogg"> <track src="file-en.vtt" kind="subtitles" srclang="en" label="English"> </video>

Related HTML tags and Useful Links:

  • <audio> - used to play audio on the page
  • <video> - used to play video on the page
  • Learn how to use audio and video tags