files/en-us/web/api/texttrack/index.md
{{APIRef("WebVTT")}}
The TextTrack interface of the WebVTT API represents a text track associated with a media element.
An object of this type owns the list of {{domxref("VTTCue")}} objects that will be displayed over the video at various points.
TextTrack objects can be added to a {{domxref("HTMLVideoElement")}} or {{domxref("HTMLAudioElement")}} element using the {{domxref("HTMLMediaElement.addTextTrack()")}} method, which has the same effect as adding text tracks declaratively using {{htmlelement("track")}} elements inside a {{htmlelement("video")}} or {{htmlelement("audio")}} element.
The TextTrack objects are stored in a {{domxref("TextTrackList")}}, which can be retrieved using the {{domxref("HTMLMediaElement.textTracks")}} property.
{{InheritanceDiagram}}
This interface also inherits properties from {{domxref("EventTarget")}}.
""). If the TextTrack is associated with a {{HTMLElement("track")}} element, then the track's ID matches the element's ID.TextTrack describes. It must be one of the permitted values.""), in which case a custom label may need to be generated by your code using other attributes of the track, if the track's label needs to be exposed to the user."en-US" for United States English or "pt-BR" for Brazilian Portuguese.disabled, unless the {{HTMLElement("track")}} element's default boolean attribute is set to true — in which case the default mode is showing.This interface also inherits methods from {{domxref("EventTarget")}}.
[!NOTE] The {{domxref("TextTrackCue")}} interface is an abstract class used as the parent for other cue interfaces such as {{domxref("VTTCue")}}. Therefore, when adding or removing a cue you will be passing in one of the cue types that inherit from
TextTrackCue.
cuechange
oncuechange property.The following example adds a new TextTrack to a video, then sets it to display using {{domxref("TextTrack.mode")}}.
let video = document.querySelector("video");
let track = video.addTextTrack("captions", "Captions", "en");
track.mode = "showing";
{{Specifications}}
{{Compat}}