HTML & CSS Interview Question #46
What is the <track> element used for?
Forms, Validation, Metadata, Media, Responsive Images & Accessibility Mid-Level Intermediate
Quick Interview Answer
track provides timed text associated with audio or video. It can supply captions, subtitles, descriptions, chapters, or metadata, commonly using WebVTT files.
Detailed Explanation
track provides timed text associated with audio or video. It can supply captions, subtitles, descriptions, chapters, or metadata, commonly using WebVTT files.
Captions are particularly important for accessibility because they communicate spoken dialogue and relevant audio information to users who cannot hear the soundtrack. The kind, srclang, and label attributes describe the track.
Code Example
<video controls>
<source src="lesson.mp4"
type="video/mp4">
<track kind="captions"
src="lesson-en.vtt"
srclang="en"
label="English"
default>
</video>