HTML <track> Tag

HTML Tag

HTML <track> Tag


The <track> tag defines subtitles, captions, descriptions, chapters, or metadata for either <audio> or <video> media element. The tag is a child tag of these tags.

Syntax

<[audio | video]>
  ...
   <track src="...">
  ...
</[audio | video]>
The closing tag (</track>) is not obligatory.

Example

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      video {
        width: 300px; 
        height: 200px;
        border: 1px solid #666;
      }
    </style>
  </head>
  <body>
    <video controls muted src="/build/videos/arcnet.io(7-sec).mp4">
      <track default kind="subtitles" srclang="en" src="/build/videos/arcnet.io(7-sec).mp4"/>
    </video>
    <p>Some information about video</p>
  </body>
</html>

Attributes

AttributeValueDescription
defaultdefaultSpecifies that the track should be enabled unless the user's preferences indicate that another track is more appropriate. This is used on one track element per media element.
kindDefines the kind of text track.
captionsTranslation of dialogue and sound effects.
chaptersChapter titles for better navigation.
descriptionsA textual description of the video content.
metadataContent used by scripts ( not visible for the user).
subtitlesSubtitles in a video.
labeltextSpecifies a user-readable title of the text track
srcURLSets the path of the track.
srclanglanguage_codeSets the language of the track text data (must be defined if kind = "subtitles").

The <track> tag also supports the Global attributes and the Event Attributes.
Reactions

Post a Comment

0 Comments

close