--- title: slug: Web/HTML/Element/track tags: - Elemento - HTML - HTML5 - Web - legenda translation_of: Web/HTML/Element/track ---
{{HTMLRef}}

O elemento HTML <track> é usado como filho dos elementos de mídia{{HTMLElement("audio")}} e {{HTMLElement("video")}}. Ele permite que você especifique faixas de texto temporizadas (ou dados baseados em tempo), por exemplo, para lidar automaticamente com legendas. As faixas são formatadas em WebVTT format (arquivos .vtt) — Web Video Text Tracks or Timed Text Markup Language (TTML).

{{EmbedInteractiveExample("pages/tabbed/track.html", "tabbed-standard")}}
Categorias de conteúdo Nenhuma
Conteúdo permitido Nenhum, é um {{Glossary("empty element")}}.
Omissão de tag Como é um elemento vazio, a tag inicial deve estar presente e a tag final não deve estar presente.
Permite Parentes Um elemento de mídia, antes de qualquer conteúdo de fluxo.
Funções ARIA permitidas Nenhum
Interface DOM {{domxref("HTMLTrackElement")}}

Atributos

Este elemento inclui os atributos globais.

{{htmlattrdef("default")}}
This attribute indicates that the track should be enabled unless the user's preferences indicate that another track is more appropriate. This may only be used on one track element per media element.
{{htmlattrdef("kind")}}
How the text track is meant to be used. If omitted the default kind is subtitles. If the attribute is not present, it will use the subtitles. If the attribute contains an invalid value, it will use metadata. (Versions of Chrome earlier than 52 treated an invalid value as subtitles.) The following keywords are allowed:
{{htmlattrdef("label")}}
A user-readable title of the text track which is used by the browser when listing available text tracks.
{{htmlattrdef("src")}}
Address of the track (.vtt file). Must be a valid URL. This attribute must be specified and its URL value must have the same origin as the document — unless the {{HTMLElement("audio")}} or {{HTMLElement("video")}} parent element of the track element has a crossorigin attribute.
{{htmlattrdef("srclang")}}
Language of the track text data. It must be a valid BCP 47 language tag. If the kind attribute is set to subtitles, then srclang must be defined.

Usage notes

The type of data that track adds to the media is set in the kind attribute, which can take values of subtitles, captions, descriptions, chapters or metadata. The element points to a source file containing timed text that the browser exposes when the user requests additional data.

A media element cannot have more than one track with the same kind, srclang, and label.

Examples

<video controls poster="/images/sample.gif">
   <source src="sample.mp4" type="video/mp4">
   <source src="sample.ogv" type="video/ogv">
   <track kind="captions" src="sampleCaptions.vtt" srclang="en">
   <track kind="descriptions"
     src="sampleDescriptions.vtt" srclang="en">
   <track kind="chapters" src="sampleChapters.vtt" srclang="en">
   <track kind="subtitles" src="sampleSubtitles_de.vtt" srclang="de">
   <track kind="subtitles" src="sampleSubtitles_en.vtt" srclang="en">
   <track kind="subtitles" src="sampleSubtitles_ja.vtt" srclang="ja">
   <track kind="subtitles" src="sampleSubtitles_oz.vtt" srclang="oz">
   <track kind="metadata" src="keyStage1.vtt" srclang="en"
     label="Key Stage 1">
   <track kind="metadata" src="keyStage2.vtt" srclang="en"
     label="Key Stage 2">
   <track kind="metadata" src="keyStage3.vtt" srclang="en"
     label="Key Stage 3">
   <!-- Fallback -->
   ...
</video>

Specifications

Specification Status Comment
{{SpecName('HTML WHATWG','embedded-content.html#the-track-element','track element')}} {{Spec2('HTML WHATWG')}}  
{{SpecName("HTML5 W3C", "embedded-content-0.html#the-track-element", "track element")}} {{Spec2("HTML5 W3C")}} Initial definition

Compatibilidade com navegadores

{{Compat("html.elements.track")}}

See also