HTML <track> tag
HTML <track> tag is used to define time-based text tracks for a media file. The <track> tag must use as child element of <audio> and <video> elements.
The <track> tag is used to add subtitle, caption, or any other form of text which displayed when a media file plays.
HTML <track> is new tag in HTML5.
Following are some specifications about the HTML <track> tag
|Start tag/End tag
||Only start tag(End tag forbidden)
Test it Now
In the above example, we have used flower.vtt file to add subtitle in the video file. Following is the flower.vtt file:
How to create WEBVTT file:
Following are some basic steps to create WEBVTT file for <track> tag:
- Open text editor in your PC such as Notepad
- Write WEBVTT as the first line in the editor
- Leave a blank line
- Specify the time duration in the proper format (you can also provide numbering and add CSS).
- Enter and write your text which you want to add a subtitle or caption, and repeat step 3 to 5 until you finish it.
- Save it using .vtt extension.
Now your WEBVTT file is ready to use.
||It specifies that the track should be enabled unless the user?s preferences indicate that another track is more important.
|It specifies that which type of text track you want to add.
||It specifies the title of the text track.
||It defines the URL of the track file.
||It defines the language of the track text content, such as English, Germany, etc.
The <track> tag supports the Global attributes in HTML.
The <track> tag supports the Event attributes in HTML.
|Element|| Chrome|| IE|| Firefox|| Opera|| Safari|