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 -

AttributeDescriptionValues
srcSpecifies the location of text trackURL.

Optional Attributes -

AttributeDescriptionValues
defaultSpecify automatically enables trackingDefault
kindSpecifies the text track kindsubtitles (default) captionsdescriptionschaptersmetadata
labelSpecifies the text track titleText.
srclangSpecifies the text track languageLanguage_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>

Output -