<track> Tag in HTML | Adding Text Tracks to Media

The <track> tag in HTML is used to specify text tracks (such as subtitles, captions, or descriptions) for media elements like <video> and <audio>. It allows users to better understand media content, making it accessible to a wider audience.

Key Points on <track> Tag:

Syntax of <track> Tag:

Syntax Example

<video controls>
            <source src="movie.mp4" type="video/mp4">
            <track src="subtitles_en.vtt" kind="subtitles" srclang="en" label="English" default>
        </video>

Example of Using <track> Tag:

This example shows a video with an English subtitle track.

Code Example

<video controls width="400">
            <source src="sample_video.mp4" type="video/mp4">
            <track src="subtitles_en.vtt" kind="subtitles" srclang="en" label="English" default>
            Your browser does not support the video tag.
        </video>

Output

Attributes of <track> Tag:

Best Practices:

The <track> tag is a powerful feature for enhancing media accessibility. Adding subtitles, captions, and other types of tracks allows users to fully engage with content, especially when audio may be difficult to hear or understand.