--- title: TextTrack slug: Web/API/TextTrack tags: - API - Interface - Media - NeedsTranslation - Reference - TextTrack - TopicStub - Web - WebVTT translation_of: Web/API/TextTrack ---
{{APIRef("WebVTT")}}

The TextTrack interface—part of the API for handling WebVTT (text tracks on media presentations)—describes and controls the text track associated with a particular {{HTMLElement("track")}} element.

Properties

This interface also inherits properties from {{domxref("EventTarget")}}.

{{domxref("TextTrack.activeCues")}} {{readonlyInline}}
A {{domxref("TextTrackCueList")}} object listing the currently active set of text track cues. Track cues are active if the current playback position of the media is between the cues' start and end times. Thus, for displayed cues such as captions or subtitles, the active cues are currently being displayed.
{{domxref("TextTrack.cues")}} {{readonlyInline}}
A {{domxref("TextTrackCueList")}} which contains all of the track's cues.
{{domxref("TextTrack.id")}} {{readonlyInline}}
A {{domxref("DOMString")}} which identifies the track, if it has one. If it doesn't have an ID, then this value is an empty string (""). If the TextTrack is associated with a {{HTMLElement("track")}} element, then the track's ID matches the element's ID.
{{domxref("TextTrack.inBandMetadataTrackDispatchType")}} {{readonlyInline}}
Returns a {{domxref("DOMString")}} which indicates the track's in-band metadata track dispatch type. needs details
{{domxref("TextTrack.kind")}} {{readonlyInline}}
Returns a {{domxref("DOMString")}} indicating what kind of text track the TextTrack describes. The value must be one of those in the TextTrackKind enum.
{{domxref("TextTrack.label")}} {{readonlyInline}}
A human-readable {{domxref("DOMString")}} which contains the text track's label, if one is present; otherwise, this is an empty string (""), 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.
{{domxref("TextTrack.language")}} {{readonlyInline}}
A {{domxref("DOMString")}} which specifies the text language in which the text track's contents is written. The value must adhere to the format specified in the Tags for Identifying Languages (BCP 47) document from the IETF, just like the HTML {{htmlattrxref("lang")}} attribute. For example, this can be "en-US" for United States English or "pt-BR" for Brazilian Portuguese.
{{domxref("TextTrack.mode")}}
A {{domxref("DOMString")}} specifying the track's current mode. Changing this property's value changes the track's current mode to match. Permitted values are listed under Text track mode constants. The default is disabled, unless the {{HTMLElement("track")}} element's {{htmlattrxref("default", "track")}} Boolean attribute is specified, in which case the default mode is started.

Events

cuechange
Fired when cues are entered and exited. A given text cue appears when the cue is entered and disappears when the cue is exited.
Also available via the oncuechange property.

Methods

This interface also inherits methods from {{domxref("EventTarget")}}.

{{domxref("TextTrack.addCue()")}}
Adds a cue (specified as a {{domxref("TextTrackCue")}} object to the track's list of cues.
{{domxref("TextTrack.removeCue()")}}
Removes a cue (specified as a {{domxref("TextTrackCue")}} object from the track's list of cues.

Example

tbd

Specifications

Specification Status Comment
{{ SpecName('HTML WHATWG', '#texttrack', 'TextTrack') }} {{ Spec2('HTML WHATWG') }}

Browser compatibility

{{Compat("api.TextTrack")}}

See also