Prejsť na hlavný obsah
← 📄 HTML & the platform·Modul A4 · Lekcia 7
ÚlohaBuild 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>: ovládacie prvky, plagát, <track>

100 XP8 min
Teória

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.
🔒

Zaregistruj sa a začni programovať

Teória je otvorená pre každého. Editor, živý náhľad a kontrola sa odomknú so 7-dňovou bezplatnou skúškou — karta potrebná, zruš kedykoľvek.

Registrácia — bezplatná skúška →

Prvých 10 lekcií v každej trase je zdarma. Karta nie je potrebná.

← PredchádzajúcaĎalšia lekcia →

Jeden tip k Pythonu alebo webu denne — e-mailom

Krátke, ručne písané, žiadny spam. Odhlásiť jedným klikom.