Embedding Videos
Overview
You can embed videos in an HTML page using the <video> tag. This allows you to play video files directly on the webpage without needing external players.
<video width="640" height="360" controls>
<source src="video.mp4" type="video/mp4">
</video>
srcpoints to the video filecontrolsadds playback controls like play, pause, and volumewidthandheightset the display size of the video
<video> vs. <iframe>
Using <video>
Using a <video>:
<video class="video-background"
autoplay
loop
muted
playsinline
poster="https://abc.xyz/~/media/store/banner/banner.jpg?rev=12345678">
<source src="https://player.vimeo.com/progressive_redirect/file.mp4?loc=external&signature=876945321"
type="video/mp4">
</video>
Using <iframe>
You can also use <iframe> if you want adaptive streaming or less hassle:
<iframe
src="https://player.vimeo.com/video/VIDEO_ID?autoplay=1&loop=1&background=1&muted=1"
frameborder="0"
allow="autoplay; fullscreen"
allowfullscreen>
</iframe>
What autoplay=1&loop=1&background=1&muted=1 does:
- Removes title, controls, logo, everything
- Enables looping and autoplay
- Makes the video behave like a background video
Comparison
| Feature | <video> Tag | <iframe> Embed |
|---|---|---|
| Raw video file (e.g. .mp4) | ✅ Yes | ❌ No |
| YouTube video support | ❌ Not supported | ✅ Required |
| Full control with HTML5 | ✅ Total control | ⚠️ Limited (YouTube API needed for more control) |
| Autoplay & Loop (YouTube) | ❌ Not possible via <video> | ✅ Works via iframe + URL params |
When to Use <video>
- You have a .mp4, .webm, or .ogg file
- You're hosting it yourself or using a direct media file URL (like from Azure Blob, S3, or Vimeo direct stream)
When to Use <iframe>
- You're embedding a video from YouTube, Vimeo, or another streaming service
- You don’t have access to a raw media file
Canva
Using a Canva video:
<div class="video-background"
style="position: relative;
width: 100%;
height: 0;
padding-top: 56.25%;
overflow: hidden;
border-radius: 8px;
box-shadow: 0 2px 8px rgba(63,69,81,0.16);">
<iframe
loading="lazy"
style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: none;"
src="https://www.canva.com/design/abcdefg/jklmnop/watch?embed"
allowfullscreen
allow="fullscreen">
</iframe>
</div>
Notes:
- The
padding-top: 56.25%preserves the responsive layout for a 16:9 aspect ratio - Since Canva doesn't use native video tags,
posterandsourcedoesn't work here
autoplay and loop not supported on Canva
Canva doesn’t officially support autoplay or loop through URL parameters because of browser security rules. This means embedded videos will show a "play" button, which is not ideal for using videos as a webpage background.
If you need autoplay or loop, download the video from Canva and host it yourself using a native <video> tag. This way, you can control autoplay, loop, mute, and more.
Youtube
Using a Youtube video:
<iframe
class="video-background"
src="https://www.youtube.com/embed/VIDEO_ID?autoplay=1&mute=1&loop=1&playlist=VIDEO_ID"
frameborder="0"
allow="autoplay; fullscreen"
allowfullscreen>
</iframe>
Replace VIDEO_ID with your actual YouTube video ID (from https://www.youtube.com/watch?v=VIDEO_ID)
Notes:
autoplay=1– starts playing automaticallymute=1– required for autoplay to work in most browsersloop=1– loops the videoplaylist=VIDEO_ID– this is required for looping to work (even though it's not a playlist; it's a YouTube quirk)
For smoother experience:
- Add
controls=0if you don’t want playback buttons visible. - Add
modestbranding=1&rel=0to avoid related video ads or logos.