Code has been added to clipboard!

HTML track Tag

Reading time 2 min
Published Jun 29, 2017
Updated Sep 11, 2019

HTML track Tag: Main Tips

  • Media elements like <video> and <audio> can use text tracks. They are visible while the media is playing, and defined by track HTML tags.
  • The track tag is newly added in HTML5.
  • You don't need to use a closing tag.

Using track: HTML Media Text

The track tag is useful when defining HTML subtitles, captions, or other media text. It defines the text tracks for all the media elements:

Example
<video controls width="325" height="245">
  <source src="random_video.mp4" type="video/mp4">
  <source src="track_video.mp4" type="video/mp4">
  <track src="subtitles_en.vtt" kind="subtitles" srclang="en" label="English">
  <track src="lithuanian_subtitles_lt.vtt" kind="subtitles" srclang="lt" label="Lithuanian">
</video>

The text must be in the Web Video Text Tracks format and have a .vvt extension. You can also specify the timing of the track, which is crucial for HTML subtitles.

Available track Tag Attributes

How to add subtitles to a video? How to include captions or descriptions? First of all, you need to specify the location of the text track you need.

src is required to include. It defines the source of the track file (an URL address):

Example
<track src="subtitles_en.vtt">

kind sets the kind of the text track:

Example
<track src="subtitles_en.vtt" kind="subtitles" srclang="en">

There are five possible values for this attribute:

Value Definition
Subtitles The default kind of track, providing translation of the video, as well as additional content (i.e., time or place).
Metadata Used by scripts and not accessible by the user
Chapters Used by the user to navigate the media
Captions Provide transcription and translation of the video, as well as non-verbal information (i.e., sound effects). Might be used by deaf or hearing-impaired users, or displayed when the sound is muted.
Descriptions Describe the video in text. Might be used by blind or vision-impaired users, or displayed when the browser can't show the video.

default sets the track to be enabled by default:

Example
<track src="subtitles_en.vtt" default>

label defines the title of the text track:

Example
<track src="subtitles_en.vtt" kind="subtitles" srclang="en" label="English">

When the value of kind is HTML subtitles, you must also include the srclang attribute. It sets the language for the track text:

Example
<track src="subtitles_en.vtt" kind="subtitles" srclang="en">

Note: when using srclang, make sure you define the language in a valid BCP 47 language subtag.

Browser Support

Chrome
23+
Edge
All
Firefox
-
IE
10+
Opera
12.1+
Safari
6+

Mobile Browser Support

Chrome
25+
Firefox
-
Opera
-
Safari
-
Basics
Introduction
Syntax
Editors
Basic Examples
Head Section
<!DOCTYPE>
Tags and Elements
Semantic Elements
Tags Reference
Attributes
Comments
Block and Inline Elements
Forms
Form Elements
Input
Responsive Web Design
Inline Scripts
Uniform Resource Locator
Redirect
XHTML
Geolocation
Drag and Drop
Local Storage
Web Workers
Server-Sent Events
Character Encoding
Text Formatting
Quotation and Citation Elements
Headings
Paragraphs
Links
Tables
Lists
Symbols
Space
Tab
Styles
Computer Code
Layout
Classes
Colors
Images
iframes
Audio Player
Video Player
YouTube Videos
Multimedia
Canvas
SVG
<!-- -->
<a>
<abbr>
<acronym> DEPRECATED
<address>
<applet> DEPRECATED
<article>
<aside>
<audio>
<b>
<base>
<basefont> DEPRECATED
<bdi>
<bdo>
<big> DEPRECATED
<blink> DEPRECATED
<blockquote>
<body>
<br>
<button>
<canvas>
<caption>
<center> DEPRECATED
<cite>
<code>
<col>
<colgroup>
<datalist>
<dd>
<del>
<details>
<dfn>
<dialog>
<dir> DEPRECATED
<div>
<dl>
<dt>
<em>
<embed>
<fieldset>
<figcaption>
<figure>
<font> DEPRECATED
<footer>
<form>
<frame> DEPRECATED
<frameset> DEPRECATED
<h1> – <h6>
<head>
<header>
<hr>
<html>
<i>
<iframe>
<img>
<input>
<ins>
<kbd>
<keygen> DEPRECATED
<label>
<legend>
<li>
<link>
<main>
<map>
<mark>
<menu>
<menuitem> DEPRECATED
<meta>
<meter>
<nav>
<noframes> DEPRECATED
<noscript>
<object>
<ol>
<optgroup>
<option>
<output>
<p>
<param>
<pre>
<progress>
<q>
<rp>
<rt>
<ruby>
<s>
<samp>
<script>
<section>
<select>
<small>
<source>
<span>
<strike> DEPRECATED
<strong>
<style>
<sub>
<summary>
<sup>
<table>
<tbody>
<td>
<tfoot>
<th>
<thead>
<time>
<title>
<tr>
<track>
<tt> DEPRECATED
<u>
<ul>
<var>
<video>
<wbr>