Skip to main content
Albero Academy

Audio, Video & Embeds

Add native audio and video with captions, and embed external content — maps, videos, widgets — safely with iframes.

Chapter 12HTML13 min readBeginner friendly
  • #HTML
  • #Video
  • #Embeds

The web plays media natively — no plugins. This chapter covers the <video> and <audio> elements, adding captions for accessibility, and embedding external content (a YouTube video, a map, a payment widget) with <iframe>.

Video

native video
<video controls width="640" poster="thumbnail.jpg" preload="metadata">
<source src="lesson.mp4" type="video/mp4">
<source src="lesson.webm" type="video/webm">
Your browser doesn't support video.
</video>
  • controls shows the play/pause UI; poster is the preview frame.
  • Multiple <source> tags let the browser pick a format it supports.
  • autoplay only works when combined with muted (browsers block sound-on autoplay).

Audio

native audio
<audio controls preload="none">
<source src="podcast.mp3" type="audio/mpeg">
<source src="podcast.ogg" type="audio/ogg">
</audio>

Captions & tracks

Add a <track> with a WebVTT file for captions or subtitles — essential accessibility, and it helps everyone in noisy or silent settings:

captions
<video controls>
<source src="lesson.mp4" type="video/mp4">
<track src="captions-en.vtt" kind="captions" srclang="en" label="English" default>
</video>

Embeds with iframe

An <iframe> embeds another page inside yours — YouTube, Google Maps, a form widget. Add title for accessibility and loading="lazy" for performance:

embedding external content
<iframe
src="https://www.youtube.com/embed/VIDEO_ID"
title="Course intro video"
width="560" height="315"
loading="lazy"
allowfullscreen></iframe>

Practice

Add a captioned <video> with a poster and two source formats, an <audio> player, and a lazy-loaded YouTube <iframe> with a proper title. Confirm the caption track toggles in the player.

Key takeaways

  1. 01<video>/<audio> play natively with controls; multiple <source> tags provide format fallbacks.
  2. 02autoplay requires muted; poster sets the preview frame.
  3. 03Add <track kind="captions"> (WebVTT) — always caption instructional video.
  4. 04<iframe> embeds external pages (YouTube, maps); add title and loading="lazy".
  5. 05Only embed trusted sources; use the sandbox attribute to restrict untrusted iframes.