WebVTT subtitles: write cues and timestamps correctly
Create a basic WebVTT subtitle file, understand cue timing and separators, connect it to HTML video, and troubleshoot common display problems.
Create a basic WebVTT subtitle file
WebVTT (Web Video Text Tracks) is a UTF-8 text format for displaying timed text—such as subtitles, captions, or chapters—in sync with audio or video. A basic file has a WEBVTT header, cue blocks with start and end timestamps, and blank lines between blocks.
WEBVTT
00:00:01.200 --> 00:00:03.500
Hello.
00:00:03.600 --> 00:00:05.900
This is a WebVTT subtitle example.The header is followed by a blank line. Each cue has a timing line with a start time, spaces, the exact arrow -->, spaces, and an end time. Text follows on the next line. A blank line ends the cue. The sample wording and times are illustrative, not measured from a real video.
Timing and block rules
| Item | Rule |
|---|---|
| Timestamp | mm:ss.ttt or hh:mm:ss.ttt; milliseconds use three digits |
| Interval | End must be later than start |
| Order | Cue start times stay in ascending order |
| Overlap | Cues may overlap; check that the rendered text remains readable |
| Separators | A blank line separates cues; a blank line inside text ends that cue |
| File | Save as UTF-8, usually with .vtt; the MIME type is text/vtt |
Minutes and seconds range from 00 to 59; milliseconds from 000 to 999. For times of an hour or more, include hours. Overlapping subtitle cues are allowed by the format, although they may be hard to read. Optional cue positioning settings can be added after the timing line; begin with defaults unless you need a specific layout. NOTE blocks are author comments, not shown to viewers. STYLE blocks must appear before cues.
Attach a track to HTML video
<video controls src='lesson.mp4'>
<track kind='subtitles' src='en.vtt' srclang='en' label='English' default>
</video>src points to the VTT file, srclang identifies the text language, and label is the name shown in the selection menu. Add a separate track for each language. This is an HTML <video> example; a hosting service or custom player may use a different setup.
Save and check playback
Save the text as UTF-8 with a `.vtt` extension.
Confirm `WEBVTT` is the first header and is followed by a blank line.
Check every `-->`, timestamp, and interval; ensure start times are ordered.
Separate cues with blank lines, but do not put blank lines inside cue text.
If text contains restricted characters such as `<` or `&`, use WebVTT character references where required.
Turn captions on in the player and watch the whole clip. Check timing, spelling, encoding, and whether text obscures important visuals.
Common problems
**Track is missing:** check the `WEBVTT` header, file URL, `.vtt` extension, and `text/vtt` response type.
**Only part of the file appears:** look for blank lines inside a cue and missing separators between cues.
**No cue appears or timing is wrong:** check timestamp punctuation and digits, the arrow, start/end order, and the media duration.
**Text is garbled:** resave as UTF-8 and check special-character references.
**Overlapping dialogue is hard to read:** overlap can be valid syntax, but adjust or split cues according to your editorial rules and review in the actual player.
Valid syntax does not guarantee good subtitles. WebVTT structures timed text; compare wording and timing with the source media. For guidance on which sounds to include, see Closed captions.
References
[W3C, WebVTT: The Web Video Text Tracks Format](https://www.w3.org/TR/webvtt1/)
[MDN, Web Video Text Tracks Format (WebVTT)](https://developer.mozilla.org/en-US/docs/Web/API/WebVTT_API/Web_Video_Text_Tracks_Format)
[MDN, Adding captions and subtitles to HTML video](https://developer.mozilla.org/en-US/docs/Web/Media/Guides/Audio_and_video_delivery/Adding_captions_and_subtitles_to_HTML5_video).