Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP C C++ C# AWS W3.CSS HOW TO BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS DSA TYPESCRIPT ANGULAR ANGULARJS GIT POSTGRESQL SQLITE MONGODB ASP AI R GO KOTLIN SWIFT SASS VUE GEN AI SCIPY CYBERSECURITY DATA SCIENCE INTRO TO PROGRAMMING INTRO TO HTML & CSS BASH RUST DART PLAYWRIGHT TOOLS MATH SHEETS POWER BI

HTML Tutorial

HTML HOME HTML Introduction HTML Editors HTML Basic HTML Elements HTML Attributes HTML Headings HTML Paragraphs HTML Styles HTML Project I HTML Formatting HTML Quotations HTML Comments HTML Colors HTML CSS HTML Project II HTML Links HTML Images HTML Favicon HTML Page Title HTML Tables HTML Lists HTML Project III HTML Block & Inline HTML Div HTML Classes HTML Id HTML Project IV HTML Global Attributes HTML Buttons HTML Iframes HTML JavaScript HTML File Paths HTML Head HTML Layout HTML Responsive HTML Project V HTML Computercode HTML Semantics HTML Project VI HTML Dialog HTML Details HTML Style Guide HTML Entities HTML Symbols HTML Emojis HTML Character Sets HTML Languages HTML URL Encoding HTML Performance HTML SEO

HTML Forms

HTML Forms HTML Form Attributes HTML Form Elements HTML Input Types HTML Input Attributes Input Form Attributes HTML Form Validation HTML Progress and Meter HTML Project VII

HTML Graphics

HTML Canvas HTML SVG

HTML Media

HTML Media HTML Video HTML Audio HTML YouTube HTML Project VIII

Web Accessibility

Web Accessibility ARIA Attributes Keyboard Focus and tabindex Landmarks Skip Links Color Contrast

Web APIs

Web APIs Geolocation API Drag and Drop API Popover API Web Storage API Web Workers API Server-Sent Events API

HTML Cert

HTML Certificate

HTML Examples

HTML Examples HTML Videos HTML Editor HTML Quiz HTML Exercises HTML Challenges HTML Projects HTML Website HTML Syllabus HTML Study Plan HTML Interview Prep HTML Summary

HTML References

HTML Tag List HTML Attributes HTML Global Attributes HTML Browser Support HTML Event Attributes HTML Colors HTML Canvas HTML Audio/Video HTML Doctypes HTML Character Sets HTML URL Encode HTML Language Codes HTML Country Codes HTTP Status Codes HTTP Request Methods PX to EM Converter Keyboard Shortcuts

HTML Video Captions


Share

What are Captions?

Captions are lines of text that show on top of a video while it plays.

They help many people:

  • people who are deaf or hard of hearing
  • people who watch without sound, like on a bus or in a library
  • people who do not speak the language of the video well

In HTML, you add captions with the <track> element and a text file in the WebVTT format.


The WebVTT File

WebVTT (Web Video Text Tracks) is a plain text file with the extension .vtt.

It lists each caption, and the time when it should show:

mov_bbb_en.vtt

WEBVTT

00:00:00.000 --> 00:00:03.000
This caption shows from 0 to 3 seconds.

00:00:03.000 --> 00:00:06.000
This caption shows from 3 to 6 seconds.

00:00:06.000 --> 00:00:10.000
And this one shows from 6 to 10 seconds.
  • The file must start with the word WEBVTT
  • Each caption starts with a start time and an end time, written as hours:minutes:seconds.milliseconds
  • The text of the caption comes on the next line
  • An empty line separates the captions

Note: Save the file with the UTF-8 character set, so all letters show correctly.



The track Element

Put a <track> element inside the <video> element, after the <source> elements:

Example

<video width="400" controls>
  <source src="mov_bbb.mp4" type="video/mp4">
  <track src="mov_bbb_en.vtt" kind="captions" srclang="en" label="English" default>
</video>
Try it Yourself »
Attribute What it does
src The address of the .vtt file
kind The kind of text, like captions or subtitles
srclang The language of the text, like en or es
label The name the user sees in the captions menu
default Turns this track on when the video starts

Captions or Subtitles?

The kind attribute says what the text is for:

Value Meaning
captions The words that are spoken, and important sounds, like [door closes]. For people who cannot hear the video
subtitles A translation of the words that are spoken. For people who do not understand the language
descriptions A text description of what happens on the screen. For people who cannot see the video
chapters Chapter titles, so the user can jump to a part of the video

Captions in Several Languages

Add one <track> element for each language.

The user can then choose a language in the video controls:

Example

<video width="400" controls>
  <source src="mov_bbb.mp4" type="video/mp4">
  <track src="mov_bbb_en.vtt" kind="subtitles" srclang="en" label="English" default>
  <track src="mov_bbb_es.vtt" kind="subtitles" srclang="es" label="Spanish">
</video>
Try it Yourself »

Only one track should have the default attribute.


Style the Captions

Use the CSS ::cue pseudo-element to change the look of the captions:

Example

video::cue {
  background-color: rgba(0, 0, 0, 0.8);
  color: yellow;
  font-size: 18px;
}
Try it Yourself »

Tip: Keep a strong contrast between the text and the background, so the captions are easy to read on any part of the video.


Things to Know

  • The .vtt file must be on the same website as the page, unless the other website allows it
  • The web server must send .vtt files with the type text/vtt
  • Users can turn captions on and off in the video controls, so add the controls attribute

Summary

  • Captions are written in a WebVTT file, with a time for each line of text
  • The <track> element connects the file to the video
  • kind, srclang, and label describe the track
  • Add one track for each language
  • Style the captions with ::cue

HTML Tag Reference

Tag Description
<video> Defines a video or movie
<track> Defines text tracks in media players

For a complete list of all available HTML tags, visit our HTML Tag Reference.


Free account

Track your progress

XP earned 0 Day streak 0 Spaces 0 League —

New

Learn in Adventure Mode W3Schools Adventure App

Coding fundamentals as bite-sized lessons and challenges.

×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookies and privacy policy.

Copyright 1999-2026 by W3Schools. All Rights Reserved. W3Schools is Powered by W3.CSS.