pub struct Track;Expand description
The <track> element - specifies timed text tracks for media elements.
§Purpose
The <track> element provides text tracks for <audio> and <video> elements. These
tracks include subtitles, captions, descriptions, chapters, and metadata. Tracks are in
WebVTT format and can be displayed or processed programmatically to enhance media accessibility
and user experience.
§Content Categories
- None (used only within
<audio>and<video>elements)
§Permitted Content Model
- None (void element)
§Common Use Cases
- Subtitles for foreign language translation
- Closed captions for deaf and hard-of-hearing users
- Audio descriptions for blind and low-vision users
- Chapter markers for video navigation
- Metadata tracks for programmatic access
§Key Attributes
kind: Type of track (“subtitles”, “captions”, “descriptions”, “chapters”, “metadata”)src: URL of the track file (WebVTTformat, required)srclang: Language of the track text (required for subtitles)label: User-readable title for the trackdefault: Enable this track by default
§Example
<!-- Video with multiple subtitle tracks -->
<video controls>
<source src="/videos/movie.mp4" type="video/mp4">
<track kind="subtitles" src="/subs/en.vtt" srclang="en" label="English" default>
<track kind="subtitles" src="/subs/es.vtt" srclang="es" label="Español">
<track kind="subtitles" src="/subs/fr.vtt" srclang="fr" label="Français">
</video>
<!-- Video with captions and descriptions -->
<video controls>
<source src="/videos/tutorial.mp4" type="video/mp4">
<track kind="captions" src="/captions/en.vtt" srclang="en" label="English Captions" default>
<track kind="descriptions" src="/descriptions/en.vtt" srclang="en" label="Audio Descriptions">
<track kind="chapters" src="/chapters/en.vtt" srclang="en" label="Chapters">
</video>
<!-- Audio with chapter markers -->
<audio controls>
<source src="/audio/podcast.mp3" type="audio/mpeg">
<track kind="chapters" src="/chapters/podcast.vtt" srclang="en" label="Episode Chapters">
<track kind="metadata" src="/metadata/podcast.vtt">
</audio>§Accessibility
- Use
kind="captions"for accessibility (includes sound effects and speaker identification) - Use
kind="subtitles"for translation only - Provide descriptions for visual content that isn’t conveyed through audio
- Ensure track files are in proper
WebVTTformat - Set appropriate default tracks based on user preferences
§WHATWG Specification
Trait Implementations§
Source§impl HtmlElement for Track
impl HtmlElement for Track
impl CanContain<Track> for Audio
impl CanContain<Track> for Video
Auto Trait Implementations§
impl Freeze for Track
impl RefUnwindSafe for Track
impl Send for Track
impl Sync for Track
impl Unpin for Track
impl UnwindSafe for Track
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more