๐ŸŽฌ HTML

Embed Audio & Video in HTML โ€” Complete Reference

๐Ÿ“… Jul 3, 2026 โฑ 3 min read

Native media needs no plugins โ€” but browsers enforce rules (especially autoplay) that trip everyone up.

Video done right

<video controls width="640" poster="thumb.jpg" preload="metadata">
  <source src="demo.webm" type="video/webm">
  <source src="demo.mp4" type="video/mp4">
  <track src="captions.vtt" kind="subtitles" srclang="en" label="English" default>
  Your browser doesn't support video.
</video>

The autoplay rule

Browsers block autoplay with sound. Background hero videos need the full combo: autoplay muted loop playsinline โ€” miss one and it won't play on mobile.

Responsive embeds (YouTube too)

.video-wrap { aspect-ratio: 16 / 9; }
.video-wrap iframe, .video-wrap video { width: 100%; height: 100%; }

Full lesson: Audio & Video.

โ† All Articles