HTMLTrackElement

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

The HTMLTrackElement interface represents an HTML <track> element within the DOM. This element can be used as a child of either <audio> or <video> to specify a text track containing information such as closed captions or subtitles.

EventTarget Node Element HTMLElement HTMLTrackElement

Instance properties

Inherits properties from its parent, HTMLElement.

HTMLTrackElement.kind

A string that reflects the kind HTML attribute, indicating how the text track is meant to be used. Possible values are: subtitles, captions, descriptions, chapters, or metadata.

HTMLTrackElement.src

A string that reflects the src HTML attribute, indicating the address of the text track data.

HTMLTrackElement.srclang

A string that reflects the srclang HTML attribute, indicating the language of the text track data.

HTMLTrackElement.label

A string that reflects the label HTML attribute, indicating a user-readable title for the track.

HTMLTrackElement.default

A boolean value reflecting the default attribute, indicating that the track is to be enabled if the user's preferences do not indicate that another track would be more appropriate.

HTMLTrackElement.readyState Read only

Returns an unsigned short that show the readiness state of the track:

Constant Value Description
NONE 0 Indicates that the text track's cues have not been obtained.
LOADING 1 Indicates that the text track is loading and there have been no fatal errors encountered so far. Further cues might still be added to the track by the parser.
LOADED 2 Indicates that the text track has been loaded with no fatal errors.
ERROR 3 Indicates that the text track was enabled, but when the user agent attempted to obtain it, this failed in some way. Some or all of the cues are likely missing and will not be obtained.
HTMLTrackElement.track Read only

Returns TextTrack is the track element's text track data.

Instance methods

No specific method; inherits methods from its parent, HTMLElement.

Events

Inherits events from its parent, HTMLElement.

Listen to these events using addEventListener() or by assigning an event listener to the oneventname property of this interface:

cuechange

Sent when the underlying TextTrack has changed the currently-presented cues. This event is always sent to the TextTrack but is also sent to the HTMLTrackElement if one is associated with the track. You may also use the oncuechange event handler to establish a handler for this event.

Usage notes

Loading of the track's text resource

The WebVTT or TTML data describing the actual cues for the text track isn't loaded if the track's mode is initially in the disabled state. If you need to be able to perform any processing on the track after the <track> is set up, you should instead ensure that the track's mode is either hidden (if you don't want it to start out being presented to the user) or showing (to initially display the track). You can then change the mode as desired later.

Specifications

Specification
HTML
# htmltrackelement

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
HTMLTrackElement
Chrome – Full support
Chrome 23 (Release date: 2012-11-06)
footnote Full support
Edge – Full support
Edge 12 (Release date: 2015-07-29)
footnote Full support
Firefox – Full support
Firefox 31 (Release date: 2014-07-22)
footnote
footnote Before Firefox 50, text tracks would only load if the <track> element is in a document.
Opera – Full support
Opera 12 (Release date: 2012-06-14)
footnote Full support
Safari – Full support
Safari 6 (Release date: 2012-07-25)
footnote Full support
Chrome Android – Full support
Chrome Android 25 (Release date: 2013-02-27)
footnote Full support
Firefox for Android – Full support
Firefox for Android 31 (Release date: 2014-07-22)
footnote
footnote Before Firefox for Android 50, text tracks would only load if the <track> element is in a document.
Opera Android – Full support
Opera Android 12 (Release date: 2012-02-25)
footnote Full support
Safari on iOS – Full support
Safari on iOS 6 (Release date: 2012-09-10)
footnote Full support
Samsung Internet – Full support
Samsung Internet 1.5 (Release date: 2013-09-25)
footnote Full support
WebView Android – Full support
WebView Android 4.4 (Release date: 2013-12-09)
footnote Full support
WebView on iOS – Full support
WebView on iOS 6 (Release date: 2012-09-10)
footnote Full support
cuechange event
Chrome – Partial support
Chrome 23 – 31 (Release date: 2012-11-06)
footnote Partial support
footnote The oncuechange event handler property is not supported.
Chrome – Full support
Chrome 32 (Release date: 2014-01-14)
footnote Full support
Edge – Full support
Edge 14 (Release date: 2016-08-02)
footnote Full support
Firefox – Full support
Firefox 68 (Release date: 2019-07-09)
footnote Full support
Opera – No support
Opera 12 – 12.1 (Release date: 2012-06-14)
unknown Support unknown
Opera – Partial support
Opera 15 – 18 (Release date: 2013-07-02)
footnote Partial support
footnote The oncuechange event handler property is not supported.
Opera – Full support
Opera 19 (Release date: 2014-01-28)
footnote Full support
Safari – Partial support
Safari 6 – 9.1 (Release date: 2012-07-25)
footnote Partial support
footnote The oncuechange event handler property is not supported.
Safari – Full support
Safari 10 (Release date: 2016-09-20)
footnote Full support
Chrome Android – Partial support
Chrome Android 25 – 31 (Release date: 2013-02-27)
footnote Partial support
footnote The oncuechange event handler property is not supported.
Chrome Android – Full support
Chrome Android 32 (Release date: 2014-01-15)
footnote Full support
Firefox for Android – Full support
Firefox for Android 68 (Release date: 2019-07-09)
footnote Full support
Opera Android – No support
Opera Android 12 – 12.1 (Release date: 2012-02-25)
unknown Support unknown
Opera Android – Partial support
Opera Android 14 – 18 (Release date: 2013-05-21)
footnote Partial support
footnote The oncuechange event handler property is not supported.
Opera Android – Full support
Opera Android 19 (Release date: 2014-01-28)
footnote Full support
Safari on iOS – Partial support
Safari on iOS 6 – 9.3 (Release date: 2012-09-10)
footnote Partial support
footnote The oncuechange event handler property is not supported.
Safari on iOS – Full support
Safari on iOS 10 (Release date: 2016-09-13)
footnote Full support
Samsung Internet – Partial support
Samsung Internet 1.5 – 1.6 (Release date: 2013-09-25)
footnote Partial support
footnote The oncuechange event handler property is not supported.
Samsung Internet – Full support
Samsung Internet 2 (Release date: 2014-10-17)
footnote Full support
WebView Android – Partial support
WebView Android 4.4 – 4.4 (Release date: 2013-12-09)
footnote Partial support
footnote The oncuechange event handler property is not supported.
WebView Android – Full support
WebView Android 4.4.3 (Release date: 2014-06-02)
footnote Full support
WebView on iOS – Partial support
WebView on iOS 6 – 9.3 (Release date: 2012-09-10)
footnote Partial support
footnote The oncuechange event handler property is not supported.
WebView on iOS – Full support
WebView on iOS 10 (Release date: 2016-09-13)
footnote Full support
default
Chrome – Full support
Chrome 23 (Release date: 2012-11-06)
footnote Full support
Edge – Full support
Edge 12 (Release date: 2015-07-29)
footnote Full support
Firefox – Full support
Firefox 31 (Release date: 2014-07-22)
footnote Full support
Opera – Full support
Opera 12 (Release date: 2012-06-14)
footnote Full support
Safari – Full support
Safari 6 (Release date: 2012-07-25)
footnote Full support
Chrome Android – Full support
Chrome Android 25 (Release date: 2013-02-27)
footnote Full support
Firefox for Android – Full support
Firefox for Android 31 (Release date: 2014-07-22)
footnote Full support
Opera Android – Full support
Opera Android 12 (Release date: 2012-02-25)
footnote Full support
Safari on iOS – Full support
Safari on iOS 6 (Release date: 2012-09-10)
footnote Full support
Samsung Internet – Full support
Samsung Internet 1.5 (Release date: 2013-09-25)
footnote Full support
WebView Android – Full support
WebView Android 4.4 (Release date: 2013-12-09)
footnote Full support
WebView on iOS – Full support
WebView on iOS 6 (Release date: 2012-09-10)
footnote Full support
kind
Chrome – Full support
Chrome 23 (Release date: 2012-11-06)
footnote Full support
Edge – Full support
Edge 12 (Release date: 2015-07-29)
footnote Full support
Firefox – Full support
Firefox 31 (Release date: 2014-07-22)
footnote Full support
Opera – Full support
Opera 12 (Release date: 2012-06-14)
footnote Full support
Safari – Full support
Safari 6 (Release date: 2012-07-25)
footnote Full support
Chrome Android – Full support
Chrome Android 25 (Release date: 2013-02-27)
footnote Full support
Firefox for Android – Full support
Firefox for Android 31 (Release date: 2014-07-22)
footnote Full support
Opera Android – Full support
Opera Android 12 (Release date: 2012-02-25)
footnote Full support
Safari on iOS – Full support
Safari on iOS 6 (Release date: 2012-09-10)
footnote Full support
Samsung Internet – Full support
Samsung Internet 1.5 (Release date: 2013-09-25)
footnote Full support
WebView Android – Full support
WebView Android 4.4 (Release date: 2013-12-09)
footnote Full support
WebView on iOS – Full support
WebView on iOS 6 (Release date: 2012-09-10)
footnote Full support
label
Chrome – Full support
Chrome 23 (Release date: 2012-11-06)
footnote Full support
Edge – Full support
Edge 12 (Release date: 2015-07-29)
footnote Full support
Firefox – Full support
Firefox 31 (Release date: 2014-07-22)
footnote Full support
Opera – Full support
Opera 12 (Release date: 2012-06-14)
footnote Full support
Safari – Full support
Safari 6 (Release date: 2012-07-25)
footnote Full support
Chrome Android – Full support
Chrome Android 25 (Release date: 2013-02-27)
footnote Full support
Firefox for Android – Full support
Firefox for Android 31 (Release date: 2014-07-22)
footnote Full support
Opera Android – Full support
Opera Android 12 (Release date: 2012-02-25)
footnote Full support
Safari on iOS – Full support
Safari on iOS 6 (Release date: 2012-09-10)
footnote Full support
Samsung Internet – Full support
Samsung Internet 1.5 (Release date: 2013-09-25)
footnote Full support
WebView Android – Full support
WebView Android 4.4 (Release date: 2013-12-09)
footnote Full support
WebView on iOS – Full support
WebView on iOS 6 (Release date: 2012-09-10)
footnote Full support
readyState
Chrome – Full support
Chrome 23 (Release date: 2012-11-06)
footnote Full support
Edge – Full support
Edge 12 (Release date: 2015-07-29)
footnote Full support
Firefox – Full support
Firefox 31 (Release date: 2014-07-22)
footnote Full support
Opera – Full support
Opera 12 (Release date: 2012-06-14)
footnote Full support
Safari – Full support
Safari 6 (Release date: 2012-07-25)
footnote Full support
Chrome Android – Full support
Chrome Android 25 (Release date: 2013-02-27)
footnote Full support
Firefox for Android – Full support
Firefox for Android 31 (Release date: 2014-07-22)
footnote Full support
Opera Android – Full support
Opera Android 12 (Release date: 2012-02-25)
footnote Full support
Safari on iOS – Full support
Safari on iOS 6 (Release date: 2012-09-10)
footnote Full support
Samsung Internet – Full support
Samsung Internet 1.5 (Release date: 2013-09-25)
footnote Full support
WebView Android – Full support
WebView Android 4.4 (Release date: 2013-12-09)
footnote Full support
WebView on iOS – Full support
WebView on iOS 6 (Release date: 2012-09-10)
footnote Full support
src
Chrome – Full support
Chrome 23 (Release date: 2012-11-06)
footnote Full support
Edge – Full support
Edge 12 (Release date: 2015-07-29)
footnote Full support
Firefox – Full support
Firefox 31 (Release date: 2014-07-22)
footnote
footnote Before Firefox 50, setting the src property did not work properly.
Opera – Full support
Opera 12 (Release date: 2012-06-14)
footnote Full support
Safari – Full support
Safari 6 (Release date: 2012-07-25)
footnote Full support
Chrome Android – Full support
Chrome Android 25 (Release date: 2013-02-27)
footnote Full support
Firefox for Android – Full support
Firefox for Android 31 (Release date: 2014-07-22)
footnote
footnote Before Firefox for Android 50, setting the src property did not work properly.
Opera Android – Full support
Opera Android 12 (Release date: 2012-02-25)
footnote Full support
Safari on iOS – Full support
Safari on iOS 6 (Release date: 2012-09-10)
footnote Full support
Samsung Internet – Full support
Samsung Internet 1.5 (Release date: 2013-09-25)
footnote Full support
WebView Android – Full support
WebView Android 4.4 (Release date: 2013-12-09)
footnote Full support
WebView on iOS – Full support
WebView on iOS 6 (Release date: 2012-09-10)
footnote Full support
srclang
Chrome – Full support
Chrome 23 (Release date: 2012-11-06)
footnote Full support
Edge – Full support
Edge 12 (Release date: 2015-07-29)
footnote Full support
Firefox – Full support
Firefox 31 (Release date: 2014-07-22)
footnote Full support
Opera – Full support
Opera 12 (Release date: 2012-06-14)
footnote Full support
Safari – Full support
Safari 6 (Release date: 2012-07-25)
footnote Full support
Chrome Android – Full support
Chrome Android 25 (Release date: 2013-02-27)
footnote Full support
Firefox for Android – Full support
Firefox for Android 31 (Release date: 2014-07-22)
footnote Full support
Opera Android – Full support
Opera Android 12 (Release date: 2012-02-25)
footnote Full support
Safari on iOS – Full support
Safari on iOS 6 (Release date: 2012-09-10)
footnote Full support
Samsung Internet – Full support
Samsung Internet 1.5 (Release date: 2013-09-25)
footnote Full support
WebView Android – Full support
WebView Android 4.4 (Release date: 2013-12-09)
footnote Full support
WebView on iOS – Full support
WebView on iOS 6 (Release date: 2012-09-10)
footnote Full support
track
Chrome – Full support
Chrome 23 (Release date: 2012-11-06)
footnote Full support
Edge – Full support
Edge 12 (Release date: 2015-07-29)
footnote Full support
Firefox – Full support
Firefox 31 (Release date: 2014-07-22)
footnote Full support
Opera – Full support
Opera 12 (Release date: 2012-06-14)
footnote Full support
Safari – Full support
Safari 6 (Release date: 2012-07-25)
footnote Full support
Chrome Android – Full support
Chrome Android 25 (Release date: 2013-02-27)
footnote Full support
Firefox for Android – Full support
Firefox for Android 31 (Release date: 2014-07-22)
footnote Full support
Opera Android – Full support
Opera Android 12 (Release date: 2012-02-25)
footnote Full support
Safari on iOS – Full support
Safari on iOS 6 (Release date: 2012-09-10)
footnote Full support
Samsung Internet – Full support
Samsung Internet 1.5 (Release date: 2013-09-25)
footnote Full support
WebView Android – Full support
WebView Android 4.4 (Release date: 2013-12-09)
footnote Full support
WebView on iOS – Full support
WebView on iOS 6 (Release date: 2012-09-10)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support
See implementation notes.
Has more compatibility info.

See also

  • The HTML element implementing this interface: <track>.