HTML <track> Tag
Example
<video width="340" height="260" controls playsinline>
<source src="video.mp4" type="video/mp4">
<source src="video.webm" type="video/webm">
<track src="ensubtitle.vtt" kind="subtitles" srclang="en" label="English">
<track src="frsubtitle.vtt" kind="subtitles" srclang="fr" label="French">
Your browser does not support the video tag.
</video>
Meaning
The <track> tag specifies text tracks for media elements <audio> and <video>.
This element is used to specify subtitles, caption files or other files containing text, that should be visible when the media is playing.
What is WebVTT files?
Web Video Text Tracks Format (WebVTT).
Web Video Text Tracks Format (WebVTT) is a format for displaying timed text tracks (such as subtitles or captions) using the <track> element.
The primary purpose of WebVTT files is to add text overlays to a <video>.
The WebVTT is a text based format, which must be encoded using UTF-8.
The MIME type of WebVTT is text/vtt.
A WebVTT file format extension is .vtt.
WEBVTT 1 00:01.000 --> 00:04.000 First subtitle 2 00:05.000 --> 00:09.000 Second subtitle
Version: HTML5
Standard Syntax
HTML: <track src="URL" srclang="languageCode" label="text">
XHTML: <track src="URL" srclang="languageCode" label="text" />
Browser Support
notes: Chrome Android, Samsung and Webview Android doesn't work for fullscreen video.
Status
Attributes
Attribute | Value | Description |
---|---|---|
default | default | Specifies that the track is to be enabled if the user's preferences do not indicate that another track would be more appropriate |
kind | captions chapters descriptions metadata subtitles |
Specifies the kind of text track |
label | text | Specifies the title of the text track |
src | URL | Required. Specifies the URL of the track file |
srclang | languageCode | Specifies the language of the track text data (required if kind="subtitles") |
Global Attributes
The <track> element also supports the Global Attributes in HTML.
Event Attributes
The <track> element also supports the Event Attributes in HTML.
By Default CSS Value(s)
None.