The
VTTCue interface—part of the API for handling WebVTT (text tracks on media presentations)—describes and controls the text track associated with a particular <track> element.
Constructor
VTTCue(startTime, endTime, text)- Returns a newly created
VTTCueobject that covers the given time range and has the given text.
Properties
This interface also inherits properties from TextTrackCue.
VTTCue.region- A
VTTRegionobject describing the video's sub-region that the cue will be drawn onto, ornullif none is assigned. VTTCue.vertical- Returns an enum representing the cue writing direction.
VTTCue.snapToLines- Returns true if the
VTTCue.lineattribute is an integer number of lines or a percentage of the video size. VTTCue.line- Returns the line positioning of the cue. This can be the string
autoor a number whose interpretation depends on the value ofVTTCue.snapToLines. VTTCue.lineAlign- Returns an enum representing the alignment of the
VTTCue.line. VTTCue.position- Returns the indentation of the cue within the line. This can be the string
autoor a number representing the percentage of theVTTCue.region, or the video size ifVTTCue.regionisnull. VTTCue.positionAlign- Returns an enum representing the alignment of the cue. This is used to determine what the
VTTCue.positionis anchored to. VTTCue.size- Returns a
doublerepresenting the size of the cue, as a percentage of the video size. VTTCue.textAlign- Returns an enum representing the alignment of all the lines of text within the cue box.
VTTCue.text- Returns a
DOMStringwith the contents of the cue.
Methods
VTTCue.getCueAsHTML- Returns the cue text as a
DocumentFragment.
Examples
var cue = new VTTCue(2, 3, 'Cool text to be displayed');
var tracks = document.querySelector('video').textTracks;
tracks[0].addCue(cue);
Once the new cue is created, it needs to be added to a TextTrack. Once added, this cue will be drawn from seconds 2 to 3 and will show the text Cool text to be displayed.
Specifications
| Specification | Status | Comment |
|---|---|---|
| WebVTT: The Web Video Text Tracks Format | Candidate Recommendation |
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Update compatibility data on GitHub
| Desktop | Mobile | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
VTTCue | Chrome Full support Yes | Edge ? | Firefox Full support 26 | IE ? | Opera Full support Yes | Safari ? | WebView Android ? | Chrome Android Full support Yes | Edge Mobile ? | Firefox Android Full support Yes | Opera Android Full support Yes | Safari iOS ? | Samsung Internet Android ? |
VTTCue() constructor | Chrome Full support Yes | Edge ? | Firefox Full support Yes | IE ? | Opera Full support Yes | Safari ? | WebView Android ? | Chrome Android Full support Yes | Edge Mobile ? | Firefox Android Full support Yes | Opera Android Full support Yes | Safari iOS ? | Samsung Internet Android ? |
align | Chrome Full support Yes | Edge ? | Firefox Full support Yes | IE ? | Opera Full support Yes | Safari ? | WebView Android ? | Chrome Android Full support Yes | Edge Mobile ? | Firefox Android Full support Yes | Opera Android Full support Yes | Safari iOS ? | Samsung Internet Android ? |
getCueAsHTML | Chrome Full support Yes | Edge ? | Firefox Full support Yes | IE ? | Opera Full support Yes | Safari ? | WebView Android ? | Chrome Android Full support Yes | Edge Mobile ? | Firefox Android Full support Yes | Opera Android Full support Yes | Safari iOS ? | Samsung Internet Android ? |
line | Chrome Full support Yes | Edge ? | Firefox Full support Yes | IE ? | Opera Full support Yes | Safari ? | WebView Android ? | Chrome Android Full support Yes | Edge Mobile ? | Firefox Android Full support Yes | Opera Android Full support Yes | Safari iOS ? | Samsung Internet Android ? |
lineAlign | Chrome No support No | Edge ? | Firefox Full support Yes | IE ? | Opera No support No | Safari ? | WebView Android ? | Chrome Android No support No | Edge Mobile ? | Firefox Android Full support Yes | Opera Android No support No | Safari iOS ? | Samsung Internet Android ? |
position | Chrome Full support Yes | Edge ? | Firefox Full support Yes | IE ? | Opera Full support Yes | Safari ? | WebView Android ? | Chrome Android Full support Yes | Edge Mobile ? | Firefox Android Full support Yes | Opera Android Full support Yes | Safari iOS ? | Samsung Internet Android ? |
positionAlign | Chrome No support No | Edge ? | Firefox Full support Yes | IE ? | Opera No support No | Safari ? | WebView Android ? | Chrome Android No support No | Edge Mobile ? | Firefox Android Full support Yes | Opera Android No support No | Safari iOS ? | Samsung Internet Android ? |
region | Chrome No support No | Edge ? | Firefox Full support Yes | IE ? | Opera No support No | Safari ? | WebView Android ? | Chrome Android No support No | Edge Mobile ? | Firefox Android Full support Yes | Opera Android No support No | Safari iOS ? | Samsung Internet Android ? |
size | Chrome Full support Yes | Edge ? | Firefox Full support Yes | IE ? | Opera Full support Yes | Safari ? | WebView Android ? | Chrome Android Full support Yes | Edge Mobile ? | Firefox Android Full support Yes | Opera Android Full support Yes | Safari iOS ? | Samsung Internet Android ? |
snapToLines | Chrome Full support Yes | Edge ? | Firefox Full support Yes | IE ? | Opera Full support Yes | Safari ? | WebView Android ? | Chrome Android Full support Yes | Edge Mobile ? | Firefox Android Full support Yes | Opera Android Full support Yes | Safari iOS ? | Samsung Internet Android ? |
text | Chrome Full support Yes | Edge ? | Firefox Full support Yes | IE ? | Opera Full support Yes | Safari ? | WebView Android ? | Chrome Android Full support Yes | Edge Mobile ? | Firefox Android Full support Yes | Opera Android Full support Yes | Safari iOS ? | Samsung Internet Android ? |
vertical | Chrome Full support Yes | Edge ? | Firefox Full support Yes | IE ? | Opera Full support Yes | Safari ? | WebView Android ? | Chrome Android Full support Yes | Edge Mobile ? | Firefox Android Full support Yes | Opera Android Full support Yes | Safari iOS ? | Samsung Internet Android ? |
Legend
- Full support
- Full support
- No support
- No support
- Compatibility unknown
- Compatibility unknown

