The <audio> element embeds sound files:
<audio controls>
<source src="audio/song.mp3" type="audio/mpeg">
<source src="audio/song.ogg" type="audio/ogg">
Your browser does not support the audio element.
</audio>
controls — shows play/pause/volume controlsautoplay — starts playing automatically (use with caution)loop — repeats the audiomuted — starts mutedpreload — hints at what to load: none, metadata, autoThe <video> element embeds video files:
<video width="640" height="360" controls poster="images/thumbnail.jpg">
<source src="video/tutorial.mp4" type="video/mp4">
<source src="video/tutorial.webm" type="video/webm">
<track src="subtitles-en.vtt" kind="subtitles" srclang="en" label="English">
Your browser does not support the video element.
</video>
controls — playback controlsautoplay — start automaticallyloop — repeatmuted — start muted (required for autoplay in most browsers)poster — thumbnail image before playbackwidth / height — dimensionsplaysinline — play inline on mobile (no fullscreen)Use the <track> element to add subtitles, captions, or descriptions:
<track src="captions-en.vtt" kind="captions" srclang="en" label="English" default>
<track src="captions-es.vtt" kind="captions" srclang="es" label="Spanish">
<track src="descriptions.vtt" kind="descriptions" srclang="en" label="English Description">
The .vtt file format (WebVTT):
WEBVTT
00:00:01.000 --> 00:00:05.000
Welcome to this tutorial.
00:00:06.000 --> 00:00:10.000
Today we'll learn about HTML media elements.
Embed another page or external content:
<iframe src="https://example.com" width="100%" height="400" style="border:0;"
allowfullscreen loading="lazy" title="Example page"></iframe>
sandbox attribute to restrict what an iframe can do:
sandbox="allow-scripts allow-same-origin"
<iframe width="560" height="315"
src="https://www.youtube.com/embed/VIDEO_ID"
title="YouTube video"
frameborder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
allowfullscreen></iframe>
width and height to prevent layout shiftsloading="lazy" on iframes for performanceCreate an HTML page that includes: