Summary -
In this topic, we described about the <track> tag along with detailed example.
The <track> tag is new in HTML5. Timed text track for media elements. The <track> tag represents external timed text tracks for media elements.
The media elements can be audio or video elements. The <track> tag specifies subtitles, caption files or other files containing text. The <track> tag is empty tag so no end tag required.
Syntax -
<track>.... </track>
Required Attributes -
Attribute | Description | Values |
---|---|---|
src | Specifies the location of text track | URL. |
Optional Attributes -
Attribute | Description | Values |
---|---|---|
default | Specify automatically enables tracking | Default |
kind | Specifies the text track kind | subtitles (default) captionsdescriptionschaptersmetadata |
label | Specifies the text track title | Text. |
srclang | Specifies the text track language | Language_code |
Example -
<!DOCTYPE html>
<html>
<head>
<title>Track tag example.. </title>
</head>
<body>
<video width="360" height="240" controls>
<source src="video/light.mp4" type="video/mp4">
<track src="subtitles.vtt" kind="subtitles" label="English">
</video>
</body>
</html>