<track> - HTML CSS HTML Tag

HTML CSS examples for HTML Tag:track

Description

The <track> element sets supplementary text tracks such as subtitle tracks and caption tracks for <audio> and <video> elements.

Summary

Permitted Parent A media element, like <audio> or <video>
Content None. It is an empty element.
Start/End TagStart tag: required, End tag: forbidden
Version New in HTML5

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html lang="en">
 <head>
  <title>Example of HTML track Tag</title>
 </head><!--  ww  w  .  j a v  a  2s  .c o m-->
 <body>
  <video controls="controls">
   <source src="your.mp4" type="video/mp4">
   <source src="your.ogv" type="video/ogg">
   <track src="subtitles_en.vtt" kind="subtitles" srclang="en" label="English"> Your browser does not support the HTML5 Video element.
  </video>
 </body>
</html>

Tag-Specific Attributes

The following table shows the attributes that are specific to the <track> tag.

Attribute Require Value Description
src Required URLURL of the track file.
default Optional default track should be enabled unless the user's preferences indicate that another track is more appropriate.
kind Optional captions chapters descriptions metadata subtitles sets the kind of text track.
label Optional text sets the title of the text track.
srclang Optionallanguage-codesets the language of the track text data. The srclang must be defined, if the kind attribute is set to subtitles.

Related Tutorials