Latest web development tutorials

HTML <track> tag

Examples

With two subtitle tracks Video:

<video width="320" height="240" controls>
<source src="forrest_gump.mp4" type="video/mp4">
<source src="forrest_gump.ogg" type="video/ogg">
<track src="subtitles_en.vtt" kind="subtitles" srclang="en"
label="English">
<track src="subtitles_no.vtt" kind="subtitles" srclang="no"
label="Norwegian">
</video>

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

IE 10, Opera and Chrome browsers support <track> tag.


Tag definitions and instructions

<Track> tag for the media element (such as <audio> and <video>) specified external text track.

This element is used to specify the subtitle files or other files that contain text, and when the media player, these files are visible.


Differences between HTML 4.01 and HTML5

<Track> tag is new in HTML5 tags.


Optional attributes

New: HTML5 new property.

属性 描述
default New default 规定该轨道是默认的。如果用户没有选择任何轨道,则使用默认轨道。
kind New captions
chapters
descriptions
metadata
subtitles
规定文本轨道的文本类型。
label New text 规定文本轨道的标签和标题。
src New URL 必需的。规定轨道文件的 URL。
srclang New language_code 规定轨道文本数据的语言。如果 kind 属性值是 "subtitles",则该属性是必需的。

Global Properties

<track> tag supports HTML global properties .


Event Properties

<track> tag supports HTML event properties .