Encodera

Thanks for reading!

Donate to the site — we work hard for you.

HTML & CSS reference

<track>

Adds subtitles or chapters to a video.

Syntax

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

Attributes

ParameterTypeDescription
srcURLA subtitle file in WebVTT format (`.vtt`).
kindsubtitles | captions | chaptersThe kind of track.
srclanglanguage codeThe language of the track.
labeltextThe name in the player menu.
default—Optional. Turn the track on by default.

Examples

A video with two subtitle tracks:

<video controls width="320">
  <source src="/media/flower.mp4" type="video/mp4">
  <track kind="subtitles" src="/media/flower-en.vtt" srclang="en" label="English" default>
  <track kind="subtitles" src="/media/flower-de.vtt" srclang="de" label="Deutsch">
</video>

Notes

Subtitles are a .vtt file with timecodes and text. It must be served from the same site as the page, otherwise the browser will not load it. captions differ from subtitles in that they also describe sounds — important for deaf viewers.

See also

  • <video> — Embeds a video in the page.
  • <audio> — Embeds an audio player.

Related recipes

In the tutorial

  • Audio and video — The video and audio tags, the controls panel, autoplay, looping, several formats with source and subtitles.

Thanks for reading!

Donate to the site — we work hard for you.