The <track> tag specifies text tracks for media elements (<audio> and <video>). You can use the <track> attribute to add subtitles to any video or audio element. Web Video Text Tracks Format (WebVTT) is a format for displaying timed text tracks (such as subtitles or captions) using the <track> element. Values that can be applied to the attribute include subtitles, descriptions, or captions.
Other attributes that can be included in the track tag:
- kind: represents the kind of text track: caption, chapter, subtitle, description
- label: represents the title of the text track
- src: is a obligatory attribute and has the role of specifying the URL of the track file
- srclang: this attribute identifies the language of the subtitles contained in that file
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title><track> tag</title> <body> <video width="480" height="320" controls> <source src="video.mp4" type="video.mp4"> <track kind="subtitles" src="Romanian.vtt" scrlang="ro" label="Romanian"> </video> </body> </html>