Images & Media

HTML <track> element

Associates timed text, usually WebVTT, with audio or video. Specify kind, src and appropriate language information. The example uses illustrative local asset paths; supply matching files before running it. Text tracks use WebVTT and have a kind and language where applicable. Captions should include significant non-speech audio, not just dialogue. Provide actual track files and test selection with native controls. It accepts global HTML attributes; individual global features may be inapplicable or restricted.

Formal Syntax & Structure

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

Parameters & Attributes

NameTypeDescription
defaultbooleanMarks a text track as the default selection, subject to user preferences. Use at most one default track per media element.
kindenumerated: subtitles, captions, descriptions, chapters, metadataClassifies a text track. Captions include relevant sound cues; subtitles typically translate or transcribe dialogue. Missing kind defaults to subtitles.
labeltextSupplies a human-readable label for optgroup, option or track. It is not the same as the label element used to name form controls.
srcURLSpecifies the resource to load for the given element, such as an image, script or media file. The resource type, loading behavior and security rules depend on the element.
srclangBCP 47 language tagDeclares the language of a text track. It is required for subtitle tracks; use a clear label to help users select the track.

Return Value

HTMLTrackElement

Content model: Empty; this void element cannot contain children and must not have an end tag. No closing tag.

Working Example

Example Snippethtml
<!doctype html><html lang="en">  <head>    <meta charset="utf-8">    <title>HTML example</title>  </head>  <body>    <video controls src="lesson.mp4">      <track kind="captions" src="captions.vtt" srclang="en" label="English" default>    </video>  </body></html>
HTML Reference