<track>: the "embed text track" element

The HTML <track> element is used as a child of the <audio> and <video> media elements. It allows you to specify timed text tracks (or time-based data), for example to automatically handle subtitles. Tracks are formatted in WebVTT format (code.vtt file) — Web Video Text Tracks.

Attributes

default

This attribute indicates that tracing should be enabled unless user preferences indicate that another tracing is more appropriate. This can only be used on one <track> element per media item.

kind

How the text track should be used. If omitted, the default type is subtitles. If the attribute contains an invalid value, it will use metadata (Chrome versions prior to 52 treated an invalid value as subtitles). The following keywords are allowed:

  • subtitles
    • Subtitles provide translation of content that cannot be understood by the viewer. For example, speech or text that is not English in an English-language film.
    • Subtitles can contain additional content, usually additional background information. For example the text at the beginning of the Star Wars films or the date, time and location of a scene.
  • captions
    • Subtitles provide a transcription and possibly a translation of the audio.
    • It can include important nonverbal information such as musical cues or sound effects. It can indicate the source of the signal (e.g. music, text, character).
    • Suitable for deaf users or when the sound is turned off.
  • descriptions
    • Textual description of the video content.
    • Suitable for blind users or where video cannot be seen.
  • chapters
    • Chapter titles should be used when the user is navigating the media resource.
  • metadata
    • Tracks used by scripts. Not visible to the user.

label

A human-readable title of the text track that is used by the browser when listing available text tracks.

src

Track address (.vtt file). Must be a valid URL. This attribute must be specified and its URL value must have the same origin as the document, unless the track element's parent <audio> or <video> element has a crossorigin attribute.

srclang

Track text data language. Must be a valid BCP 47 language tag. If the kind attribute is set to subtitles, srclang must be defined.

Usage notes

Track data types

The type of data that track adds to the media is set in the kind attribute, which can take values of subtitles, captions, or descriptions, chapters or metadata. The element points to a source file containing timed text that the browser exposes when the user requests additional data.

A media element cannot have more than one track with the same kind, srclang, and label.