Consent

This site uses third party services that need your consent.

Skip to content
Steven Roland

Track Element: Timed Text Tracks for Media

The <track> HTML element is used to specify text tracks for <video> and <audio> elements. It is a self-contained, void element that provides subtitles, captions, descriptions, chapters, or metadata to media content, enhancing accessibility and usability. The <track> element is essential for making multimedia content more accessible to users who are deaf, hard of hearing, or speak different languages.

Usage and Characteristics

The <track> element is used within <video> or <audio> elements and is not rendered directly. Instead, it provides additional information that can be displayed or used by media players. Here is an example of how the <track> tag can be used:

<video controls>
  <source src="movie.mp4" type="video/mp4">
  <track src="subtitles_en.vtt" kind="subtitles" srclang="en" label="English">
  <track src="subtitles_es.vtt" kind="subtitles" srclang="es" label="Spanish">
  Your browser does not support the video tag.
</video>

Valid Attributes for <track>

Attribute Description
src Specifies the URL of the track file.
kind Specifies the kind of text track. Possible values include subtitles, captions, descriptions, chapters, and metadata.
srclang Specifies the language of the track text data, using a valid BCP 47 language tag (e.g., en for English).
label Provides a user-readable title for the track, which is displayed in the media player.
default A Boolean attribute that indicates the track should be enabled by default. Only one track per media element can have this attribute.

Benefits and Considerations

  • Accessibility: The <track> element significantly enhances accessibility by providing subtitles and captions, making video and audio content accessible to users who are deaf or hard of hearing.

  • Multilingual Support: By offering tracks in multiple languages, the <track> element allows media content to reach a broader audience.

  • User Experience: Text tracks like chapters and descriptions can improve the user experience by providing additional context or allowing users to navigate content more easily.

In summary, the <track> element is a valuable tool for enhancing the accessibility and usability of multimedia content. It provides a way to include subtitles, captions, and other text tracks, making video and audio content more inclusive and user-friendly. By using the <track> element, developers can ensure that their media content is accessible to a wider audience.