Skip to main content
📄 HTML & the platform·Module A4 · Lesson 7
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. metadata is 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 15 lessons in each track are free. No card needed for those.

PreviousNext lesson →

Get one Python or web tip a day — by email

Short, hand-written, no spam. Unsubscribe in one click.