TaskBuild a <video> with controls, poster='/intro.jpg', width=800 height=450. Inside: <source src='/intro.mp4' type='video/mp4'> and <track kind='captions' src='/intro.vtt' srclang='en' label='English' default>.
<video>: controls, poster, <track>
100 XP8 min
Theory
The most-loaded HTML tag
<video controls
poster="/poster.jpg"
width="800" height="450"
preload="metadata">
<source src="/demo.mp4" type="video/mp4" />
<source src="/demo.webm" type="video/webm" />
<track kind="captions" src="/demo.vtt" srclang="en" label="English" default />
Your browser doesn't support video.
</video>Six things working at once:
- `controls` β show the native play/pause/scrub bar. Without it the user can't play the video.
- `poster` β image shown before play. Saves bandwidth (no need to download the first frame) and gives Lighthouse something to score before video starts.
- `preload` β
none/metadata/auto.metadatais the sane default (length + dimensions only). - Multiple `<source>` β provide MP4 + WebM. Browser picks the first it can decode.
- `<track>` β captions, subtitles, descriptions, chapters. Required for accessibility.
- Fallback text β shown to browsers that don't support video at all (vanishingly rare in 2026).
autoplay rules
Modern browsers REQUIRE all of:
<video autoplay muted playsinline />
autoplayβ opt in.mutedβ without this, autoplay is blocked (UX policy across all browsers).playsinlineβ required on iOS for inline (non-fullscreen) playback.
If you skip muted, your autoplay silently doesn't autoplay.
WebVTT captions
<track> points to a .vtt file. Format:
WEBVTT 00:00:00.000 --> 00:00:03.000 Welcome to CodeMentor. 00:00:03.000 --> 00:00:06.500 Let's get started.
π
Sign up to start coding
Theory is open to everyone. The interactive editor, live preview, and check are unlocked with a 7-day free trial β card required, cancel anytime.
Sign up β free trial βFirst 10 lessons in each track are free. No card needed for those.