Skip to content

<track> - The Track Element

Media Element HTML5

The track element specifies text tracks for <video> and <audio> elements. It provides captions, subtitles, chapter titles, and audio descriptions in WebVTT format, making media content accessible to all users.

Result
<track kind="captions" src="captions.vtt" srclang="en" label="English">

The <track> element is void (self-closing) and must be a child of <video> or <audio>.

Specifies what type of text track to display:

ValuePurposeUse Case
captionsTranscription and sound effectsFor deaf/hard of hearing users
subtitlesTranslation of dialogueFor users who don’t understand the audio language
descriptionsAudio descriptions of videoFor blind/low vision users
chaptersChapter titles for navigationFor quick navigation through media
metadataMetadata for scriptsNot visible to user, for JavaScript
Result

URL of the track file (must be WebVTT format):

<track src="captions.vtt">
<track src="https://example.com/subtitles.vtt">
<track src="/media/tracks/descriptions.vtt">

Language of the track text (BCP 47 language tag):

<track srclang="en"> <!-- English -->
<track srclang="es"> <!-- Spanish -->
<track srclang="fr"> <!-- French -->
<track srclang="de"> <!-- German -->
<track srclang="ja"> <!-- Japanese -->
<track srclang="zh-CN"> <!-- Chinese (Simplified) -->
<track srclang="pt-BR"> <!-- Portuguese (Brazil) -->

User-visible title for the track:

Result

Enables the track by default if user preferences don’t indicate otherwise:

<!-- This track loads automatically -->
<track kind="captions"
src="captions.vtt"
srclang="en"
label="English"
default>
AttributeRequiredDescriptionExample
kindNoType of text trackcaptions, subtitles, descriptions, chapters, metadata
srcYesURL of track file (WebVTT)src="captions.vtt"
srclangFor subtitles/captionsLanguage code (BCP 47)srclang="en"
labelFor subtitles/captionsUser-visible titlelabel="English"
defaultNoEnable by defaultdefault
WEBVTT
00:00:00.000 --> 00:00:03.000
Welcome to our video tutorial.
00:00:03.000 --> 00:00:07.000
Today we'll learn about HTML5 video.
00:00:07.000 --> 00:00:11.000
Let's get started!
WEBVTT
intro
00:00:00.000 --> 00:00:03.000
Welcome to our video tutorial.
section-1
00:00:03.000 --> 00:00:07.000
Today we'll learn about HTML5 video.
WEBVTT
00:00:00.000 --> 00:00:03.000
<v Speaker1>Hello, how are you?</v>
00:00:03.000 --> 00:00:05.000
<v Speaker2>I'm doing great!</v>
00:00:05.000 --> 00:00:08.000
<c.important>Important announcement</c>
00:00:08.000 --> 00:00:11.000
<b>Bold text</b> and <i>italic text</i>
WEBVTT
00:00:00.000 --> 00:00:03.000 align:start
Left-aligned caption
00:00:03.000 --> 00:00:06.000 align:end
Right-aligned caption
00:00:06.000 --> 00:00:09.000 position:50% align:middle
Centered caption
00:00:09.000 --> 00:00:12.000 line:0%
Top of video
00:00:12.000 --> 00:00:15.000 line:100%
Bottom of video

Transcription of dialogue plus sound effects for deaf/hard of hearing users:

WEBVTT
00:00:00.000 --> 00:00:02.000
[upbeat music playing]
00:00:02.500 --> 00:00:05.000
<v Narrator>Welcome to our cooking show!</v>
00:00:05.500 --> 00:00:07.000
[sizzling sounds]
00:00:07.000 --> 00:00:10.000
<v Chef>Today we're making pasta.
00:00:10.500 --> 00:00:11.500
[water boiling]

Translation of dialogue for users who understand the audio language:

WEBVTT
00:00:02.500 --> 00:00:05.000
Bienvenido a nuestro programa de cocina!
00:00:07.000 --> 00:00:10.000
Hoy vamos a hacer pasta.

Audio descriptions for blind/low vision users:

WEBVTT
00:00:00.000 --> 00:00:05.000
A chef enters a modern kitchen wearing a white apron.
00:00:10.000 --> 00:00:15.000
The chef places a pot of water on the stove.
00:00:20.000 --> 00:00:25.000
Steam rises as the water begins to boil.

Navigation markers for quick access to sections:

WEBVTT
intro
00:00:00.000 --> 00:01:30.000
Introduction
ingredients
00:01:30.000 --> 00:05:00.000
Gathering Ingredients
cooking
00:05:00.000 --> 00:15:00.000
Cooking Process
plating
00:15:00.000 --> 00:18:00.000
Plating and Presentation
conclusion
00:18:00.000 --> 00:20:00.000
Conclusion
Result

Data for scripts, not displayed to users:

WEBVTT
00:00:00.000 --> 00:00:10.000
{"products": ["apron", "pot"], "scene": "kitchen"}
00:00:10.000 --> 00:00:20.000
{"products": ["pasta", "sauce"], "scene": "cooking"}
Result
Result
Result
ModeDescription
disabledTrack not active (default)
hiddenTrack active but not displayed (useful for metadata)
showingTrack active and displayed
Result

Level A Requirements:

  • Captions for all prerecorded audio content in video
  • Audio descriptions OR full text alternative for prerecorded video

Level AA Requirements:

  • Captions for all live audio content
  • Audio descriptions for all prerecorded video

Level AAA Requirements:

  • Sign language interpretation
  • Extended audio descriptions
WEBVTT
00:00:00.000 --> 00:00:03.000
[upbeat music]
00:00:03.000 --> 00:00:06.000
<v John>Hello, welcome to the show!</v>
00:00:06.500 --> 00:00:08.000
[audience applause]
00:00:09.000 --> 00:00:12.000
<v Sarah>Thanks for having me.

Guidelines:

  • Include speaker identification
  • Describe non-speech sounds in [brackets]
  • Keep lines short (32-40 characters max)
  • Display for 1-7 seconds based on reading speed
  • Synchronize accurately with audio
  • Use proper punctuation and capitalization
Result
Result
video::cue {
color: white;
background-color: rgba(0, 0, 0, 0.8);
font-family: Arial, sans-serif;
font-size: 1.2rem;
font-weight: bold;
font-style: italic;
text-decoration: underline;
text-shadow: 1px 1px 2px black;
opacity: 0.9;
}
Result
Result

Track files must respect CORS when loaded from different origins:

<!-- Video and track from same origin: works -->
<video controls src="/video.mp4">
<track src="/captions.vtt">
</video>
<!-- Cross-origin: requires CORS headers -->
<video controls crossorigin="anonymous"
src="https://cdn.example.com/video.mp4">
<track src="https://cdn.example.com/captions.vtt">
</video>

Server configuration needed:

Access-Control-Allow-Origin: *
Content-Type: text/vtt; charset=utf-8
FeatureChromeFirefoxSafariEdge
<track> basic23+31+6+12+
WebVTT format23+31+6+12+
kind="captions"23+31+6+12+
kind="subtitles"23+31+6+12+
kind="chapters"23+31+6+12+
kind="descriptions"51+55+12.1+79+
TextTrack API23+31+6+12+
CSS ::cue23+55+6+79+
  • YouTube Auto-Captions (free, requires editing)
  • Rev.com (professional human captions)
  • 3Play Media (professional service)