This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
* Some parts of this feature may have varying levels of support.
The VTTCue interface of the WebVTT API represents a cue that can be added to the text track associated with a particular video (or other media).
A cue defines the text to display in a particular timeslice of a video or audio track, along with display properties such as its size, alignment, and position.
VTTCue()Returns a newly created VTTCue object that covers the given time range and has the given text.
This interface also inherits properties from TextTrackCue.
VTTCue.regionA VTTRegion object describing the video's sub-region that the cue will be drawn onto, or null if none is assigned.
VTTCue.verticalAn enum representing the cue writing direction.
VTTCue.snapToLinestrue if the VTTCue.line attribute indicates an integer number of lines or false if it represents a percentage of the video size. This is true by default.
VTTCue.lineRepresents the line positioning of the cue. This can be the string auto or a number whose interpretation depends on the value of VTTCue.snapToLines.
VTTCue.lineAlignAn enum representing the alignment of the VTT cue.
VTTCue.positionRepresents the indentation of the cue within the line. This can be the string auto, a number representing the percentage of the VTTCue.region, or the video size if VTTCue.region is null.
VTTCue.positionAlignAn enum representing the alignment of the cue. This is used to determine what the VTTCue.position is anchored to. The default is auto.
VTTCue.sizeRepresents the size of the cue, as a percentage of the video size.
VTTCue.alignAn enum representing the alignment of all the lines of text within the cue box.
VTTCue.textA string representing the contents of the cue.
getCueAsHTML()Returns the cue text as a DocumentFragment.
The following example adds a new TextTrack to the video, then adds cues using the TextTrack.addCue() method, with a VTTCue object as the value.
<video controls src="/shared-assets/videos/friday.mp4"></video>
video {
width: 420px;
height: 300px;
}
let video = document.querySelector("video");
let track = video.addTextTrack("captions", "Captions", "en");
track.mode = "showing";
track.addCue(new VTTCue(0, 0.9, "Hildy!"));
track.addCue(new VTTCue(1, 1.4, "How are you?"));
track.addCue(new VTTCue(1.5, 2.9, "Tell me, is the lord of the universe in?"));
track.addCue(new VTTCue(3, 4.2, "Yes, he's in - in a bad humor"));
track.addCue(new VTTCue(4.3, 6, "Somebody must've stolen the crown jewels"));
console.log(track.cues);
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
VTTCue |
33 | 79 | 31 | 20 | 8 | 33 | 31 | 20 | 8 | 2.0 | 4.4.3 | 8 |
VTTCue |
23 | 12 | 31 | ≤12.1 | 6 | 25 | 31 | ≤12.1 | 8 | 1.5 | 4.4 | 8 |
align |
23 | 79 | 31 | ≤12.1 | 6 | 25 | 31 | ≤12.1 | 8 | 1.5 | 4.4 | 8 |
getCueAsHTML |
23 | 12 | 31 | ≤12.1 | 6 | 25 | 31 | ≤12.1 | 8 | 1.5 | 4.4 | 8 |
line |
23 | 79 | 31 | ≤12.1 | 6 | 25 | 31 | ≤12.1 | 8 | 1.5 | 4.4 | 8 |
lineAlign |
No | No | 31 | No | 14.1 | No | 31 | No | 14.5 | No | No | 14.5 |
position |
23 | 79 | 31 | ≤12.1 | 6 | 25 | 31 | ≤12.1 | 8 | 1.5 | 4.4 | 8 |
positionAlign |
No | No | 31 | No | 14.1 | No | 31 | No | 14.5 | No | No | 14.5 |
region |
No | No | 59 | No | 14.1 | No | 59 | No | 14.5 | No | No | 14.5 |
size |
23 | 79 | 31 | ≤12.1 | 6 | 25 | 31 | ≤12.1 | 8 | 1.5 | 4.4 | 8 |
snapToLines |
23 | 79 | 31 | ≤12.1 | 6 | 25 | 31 | ≤12.1 | 8 | 1.5 | 4.4 | 8 |
text |
23 | 12 | 31 | ≤12.1 | 6 | 25 | 31 | ≤12.1 | 8 | 1.5 | 4.4 | 8 |
vertical |
23 | 79 | 31 | 15 | 6 | 25 | 31 | 14 | 8 | 1.5 | 4.4 | 8 |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/VTTCue