text property

Gets TextTrackCue text in un-parsed form.

This property is read-only.

HTML5 A vocabulary and associated APIs for HTML and XHTMLInternet Explorer 10



text = object.text


Property values

Type: string

A string containing the text portion of a cue.

Standards information


The text property can be used to put cue text into a div element for custom displays.

Note  To create timed text files in both Web Video Text Track (WebVTT) and Timed Text Markup Language (TTML) formats, see HTML5 Video Caption Maker on the Windows Internet Explorer test drive site.


The following example gets the list of cues from a track element, and uses the activeCues property to get the current cue. The text property is displayed below the video player.

  <script type="text/javascript">
    document.addEventListener("DOMContentLoaded", function () {  // don't run this until all DOM content is loaded 
      var track = document.getElementById("track1");
      track.addEventListener("cuechange", function () {
        var myTrack = this.track;             // track element is "this" 
        var myCues = myTrack.activeCues;      // activeCues is an array of current cues.                                                    
        if (myCues.length > 0) {
         document.getElementById("display").innerHTML = myCues[0].text;
      }, false);
    }, false);      
    <video id="video1" controls>
      <source src="video.mp4"  >
      <track id='track1' label='English captions' src="entrack.vtt" kind='subtitles' srclang='en' default >    
    <div id="display">

See also

How to use HTML5 to play video files on your webpage
Make your videos accessible with Timed Text Tracks