×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Using the Track HTML5 tag to Specify Text Tracks
 

Submitted by: Octavia Anghel(octaviaanghel@gmail.com)

Wednesday Feb 28th 2018 by Octavia Anghel

Language: Web, Expertise: Intermediate - Learn how to use the <track> HTML5 tag to specify text tracks for media elements.

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>
Home
Mobile Site | Full Site
Copyright 2018 © QuinStreet Inc. All Rights Reserved