Skip to content
Related Articles

Related Articles

Improve Article

HTML | DOM Track kind property

  • Last Updated : 10 Apr, 2019

The DOM Track kind property is used to set or return the value of the kind attribute of the track. The kind attribute is used to specify the kind of the track.

Syntax:

  • It is used to return the kind property.
    trackObject.kind
  • It is also used to set the kind property.

    trackObject.kind = “captions|metadata|chapters|subtitles|descriptions”

Value: It is either true or false which shows the default state of the track. By default, it is false.

  • captions: It defines translation of dialogue and sound effects which is also suitable for deaf users.
  • metadata: It states content used by scripts but is not shown to users.
  • chapters: It defines chapter titles which is suitable to navigate the media resource.
  • subtitles: Display subtitles in a video.
  • descriptions: It describe the textual description of the video content.



    Return Value: It returns the kind of the text track in the form of string.




    <html>
      
    <head>
        <style>
            body {
                text-align: center;
            }
              
            h1 {
                color: green;
            }
        </style>
    </head>
      
    <body>
        <h1>GeeksforGeeks</h1>
        <h2>Track kind Property</h2>
      
        <video width="100" 
               height="100"
               controls>
      
            <track src=
                   id="myTrack" 
                   kind="subtitles" 
                   srclang="en" 
                   label="English" 
                   default>
      
                <source id="myTrack2"
                        src=
                        type="video/mp4">
      
        </video>
      
        <p>
          Click the button to get the kind 
          property of the track.
      </p>
      
        <button onclick="myFunction()">
            Get kind property
        </button>
      
        <p id="gfg"></p>
        <!-- Script to get the kind property -->
        <script>
            function myFunction() {
                var x = document.getElementById(
                  "myTrack").kind;
                document.getElementById(
                  "gfg").innerHTML = x;
            }
        </script>
    </body>
      
    </html>

    Output:
    Before clicking on the button:

    After clicking on the button:

    Supported Browsers:

    • Google Chrome
    • Internet Explorer 10.0+
    • Opera

    Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.




    My Personal Notes arrow_drop_up
Recommended Articles
Page :