HTML <track> Tag

Beginner
7 min read
Updated: Nov 2026
4 examples
Live preview

Definition and Usage

The <track> element adds a timed text track (usually a WebVTT .vtt file) to <video> or <audio> — for example subtitles or closed captions shown with the media.

Set kind, src, srclang, and label so the player can list the track. Optional default enables that track when appropriate. You can nest several <track> elements for different languages or kinds.

Baseline · Widely available.

Not deprecated. Stable across browsers since about July 2015.

Void element.

<track> has no end tag and no children. It only points at an external .vtt file via src.

Same-origin src.

The track URL must be same-origin as the page unless the parent video/audio uses crossorigin.

HTML Syntax

syntax.html
<track kind=" subtitles" src="file.vtt" srclang="en">

Must be a child of <video> or <audio>. Start tag only (void). If kind is omitted, it defaults to subtitles. Invalid kind values fall back to metadata.

Attributes

Element-specific attributes on <track> (plus global attributes):

AttributeDescriptionTry it
srcURL of the WebVTT (.vtt) file — requiredTry it
kindsubtitles (default), captions, descriptions, chapters, or metadataTry it
srclangLanguage of the track (BCP 47). Required when kind="subtitles"Try it
labelUser-visible name in the player’s track menuTry it
defaultBoolean — enable this track by default (only one per media element)Try it

Global Attributes

The <track> tag also supports the Global Attributes in HTML.

Live Preview

Switch track presets and inspect the markup. Open the player’s CC / captions menu if text is not shown automatically.

<track> is a void child of <video> pointing at a .vtt file.

Player

<track kind="subtitles" src="/video/count.vtt" srclang="en" label="English" default>

HTML Examples

Short, copy-ready snippets using sample media on this site. Use Try It Yourself for a live editor.

Example 1 — Subtitles Track

Add an English subtitle file inside <video>.

HTML
<video controls src="/video/count.mp4">
  <track
    kind="subtitles"
    src="/video/count.vtt"
    srclang="en"
    label="English"
    default
  >
</video>
Try It Yourself

How It Works

  1. Put <track> inside <video> (or audio).
  2. Point src at a .vtt file.
  3. Set kind="subtitles" and srclang (required for subtitles).
  4. Add label so users see a clear name in the menu.

Example 2 — Captions Kind

Use kind="captions" when the track should cover dialogue plus important non-speech audio.

HTML
<video controls src="/video/count.mp4">
  <track
    kind="captions"
    src="/video/count.vtt"
    srclang="en"
    label="English captions"
    default
  >
</video>
Try It Yourself

How It Works

  1. Choose kind="captions" for accessibility-focused timed text.
  2. Keep a real .vtt that includes relevant non-speech cues when needed.
  3. Still set srclang and label for the menu.
  4. Players list captions separately from subtitles when both exist.

Example 3 — Multiple Languages

Offer more than one subtitle language; users pick from the track menu.

HTML
<video controls src="/video/count.mp4">
  <track kind="subtitles" src="/video/count.vtt" srclang="en" label="English" default>
  <track kind="subtitles" src="/video/count_es.vtt" srclang="es" label="Español">
</video>
Try It Yourself

How It Works

  1. Add one <track> per language file.
  2. Change srclang and label for each.
  3. Mark at most one default.
  4. Browsers may also pick based on the user’s language preferences.

Example 4 — The default Attribute

Boolean default asks the browser to enable that track unless user prefs say otherwise.

HTML
<video controls src="/video/count.mp4">
  <track
    kind="subtitles"
    src="/video/count.vtt"
    srclang="en"
    label="English"
    default
  >
</video>
Try It Yourself

How It Works

  1. Add the boolean default with no value (or default="").
  2. Use it on one track only per video/audio.
  3. The UA may still override based on user caption preferences.
  4. Users can always switch via the player track menu when multiple tracks exist.

Edge Cases & Pitfalls

Most track failures are missing VTT files, wrong origin, or incomplete attributes.

format

Use WebVTT (.vtt)

Point src at a valid WebVTT file. Other subtitle formats are not what <track> expects in HTML.

origin

Same origin unless CORS is set

Cross-origin track files need crossorigin on the media parent and correct CORS headers on the VTT host.

srclang

Required for subtitles

When kind="subtitles", include a valid srclang. Invalid kind values are treated as metadata.

unique

No duplicate kind + language + label

A media element must not have two tracks with the same kind, srclang, and label. Also use only one default.

Browser Support

The <track> element is core HTML for media text tracks. It is not a Node.js, Deno, or Bun API.

✓ Baseline · Widely available

<track>

Widely available since about July 2015. Chrome, Firefox, Safari, Edge, and Opera support WebVTT tracks on video and audio; UI for enabling captions varies by player.

95% Global support (approx.)
Google Chrome 23+
Full support
Mozilla Firefox 31+
Full support
Apple Safari 6+
Full support
Microsoft Edge 12+
Full support
Opera 12.1+
Full support
Samsung Internet All modern
Full support
Internet Explorer 10+
Supported
<track> Widely supported

Bottom line: Safe for production captions and subtitles. Ship valid .vtt files, set kind/srclang/label, and test the player’s CC menu.

Key Takeaways

  • Role: <track> links a WebVTT file to video or audio.
  • Must-haves: src, useful kind, and srclang for subtitles.
  • Kinds: subtitles, captions, descriptions, chapters, metadata.
  • Rules: void element; one default; same-origin (or CORS) for src.

One line: nest <track src="file.vtt" kind="…" srclang="…" label="…"> inside your media element.

Default CSS Settings

track is a void metadata child of media — it has no box of its own in the layout. Cue appearance is controlled by the media player and optional ::cue CSS:

default.css
track {
  display: none; /* not a visible box; cues render via the media UI */
}

video::cue {
  /* optional: style displayed cue text when supported */
}

Exact caption styling and menus differ by browser. Always test the CC control on real devices.

Frequently Asked Questions

The track element adds a timed text file (usually WebVTT) to a video or audio element — subtitles, captions, descriptions, chapters, or metadata.
WebVTT (.vtt). Point the src attribute at a .vtt file that contains timed cues.
Subtitles translate or transcribe dialogue when sound is available but not understood. Captions also include important non-speech audio (effects, music cues) for when sound is missing or hard to hear.
Yes when kind is subtitles. It must be a valid BCP 47 language tag such as en or es.
No. Only one track per media element may have the default attribute.
No. It is Baseline and widely available. Prefer it for accessible timed text on HTML media.

Next: tt

Learn the obsolete HTML tt element and modern alternatives like code.

tt tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

12 people found this page helpful