The HTML <track> tag specifies text tracks for media components audio and video This part is employed to specify subtitles, caption files, or different files containing text, that ought to be visible once the media is taking part in.Â
Note:
Syntax:
<track Attribute>
Attributes:
Specifies that, the track to enabled if the user wants to change the track.
|
Specifies the kind of text track
|
The title of the text track
|
It is for the URL of the track file
|
It tells the language of the track text data (required if kind=”subtitles”)
|
Example 1:Â In this example, we will see the implementation of <track> tag.
html
< html >
< head >
</ head >
< body style = "text-align: center" >
< h1 style = "color: green" >
GeeksforGeeks
</ h1 >
< h2 >HTML Track srclang Attribute</ h2 >
< video width = "600" height = "400" controls>
< track src =
kind = "subtitles" srclang = "en"
label = "English" >
< source id = "myTrack" src =
type = "video/mp4" >
</ video >
</ body >
</ html >
|
Output:
Example 2: Â
HTML
< html >
< head >
</ head >
< body style = "text-align: center" >
< h1 style = "color: green" >
GeeksforGeeks
</ h1 >
< h2 >HTML Track srclang Attribute</ h2 >
< video width = "700" height = "500" controls>
< track
src =
id = "myTrack1" kind = "subtitles"
srclang = "en" label = "English" >
< source id = "myTrack"
src =
type = "video/mp4" >
</ video >
</ body >
</ html >
|
Output:
Supported Browsers:
- Google Chrome 23
- Edge 12 and above
- Firefox 31 and above
- Opera 12.1 and above
- Safari 6 and above
Last Updated :
22 Dec, 2023
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...