# Using the `track` element to provide captions

ID: H95

Technology: html

Type: Technique

## When to Use

HTML

## Description

The objective of this technique is to use the HTML `track` element to specify a captions timed text track for a video element. Caption timed text tracks contain transcription or translation of the dialogue, sound effects, relevant musical cues, and other relevant audio information, suitable for when sound is unavailable or not clearly audible.

The `src` attribute of the `track` element is a URL that is the address of the text track data.

The `kind` attribute of the `track` element indicates the kind of information in the timed text. captions text tracks provide a text version of dialogue and other sounds important to understanding the video. Subtitles contain only the dialogue. If other audio information is important to understanding the video, a subtitle track will not be sufficient to meet the success criterion.

Some regions use the term "subtitle" for any visible text representation of the audio track. An author may mark up a timed text track in the language of the audio track as kind=subtitles, instead of kind=captions, and may include additional relevant audio information. It is not best practice to use subtitles in this situation, since it may confuse users who are trying to find captions, but such a timed text track would meet the requirements of Success Criterion 1.2.2.

## Examples

### Captions in one language

A `video` element for a video in the English language with an English caption track. The captions are provided in the WebVTT format.

    <video poster="myvideo.png" controls>
      <source src="myvideo.mp4" srclang="en" type="video/mp4">
      <track kind="captions" label="English" src="myvideo_en.vtt" srclang="en">
    </video>

### Captions in multiple languages

A `video` element for a video in the English language with an English caption track. The captions are provided in the WebVTT format.

    <video poster="myvideo.png" controls>
      <source src="myvideo.mp4" srclang="en" type="video/mp4">
      <source src="myvideo.webm" srclang="fr" type="video/webm">
      <track kind="captions" label="English" src="myvideo-en.vtt" srclang="en">
      <track kind="captions" label="Français" src="myvideo-fr.ttml" srclang="fr">
    </video>

## Tests

### Procedure

For each video element used to play a video:

1. Check that the video contains a `track` element of `kind` captions in the language of the video.

### Expected Results

- Check #1 is true.

## Related Techniques

- G87

## Resources

- HTML - the `track` element
- Timed Text Markup Language
- WebVTT: The Web Video Text Tracks Format
- Captionator Polyfill