Video Embed Code Generator
<div style="position:relative;border-radius:24px;overflow:hidden;width:100%;aspect-ratio:16 / 9;">
<video style="position:absolute;inset:0;width:100%;height:100%;border:0;" controls playsinline preload="metadata">
<source src="https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4" type="video/mp4">
Your browser does not support HTML5 video.
</video>
</div>
<p style="margin:4px auto 0;text-align:center;font:11px/1.4 -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;color:#a3a7b0;">Created with <a href="https://elfsight.com/tools/video-embed-code-generator/" target="_blank" rel="noopener" style="color:inherit;text-decoration:none;">Elfsight</a></p>- Click Copy code above to copy it.
- Open the page’s HTML file or template.
- Paste the code inside
<body>, where the content should appear. - Save and upload the page, then open it in a browser to check.
Need more than one video?
Show the whole video library as an interactive gallery that updates itself.
See Video Gallery for HTML →Have more than one video?
Auto-updates when you publish new videos
Carousel, grid, masonry or player with playlist
YouTube, Vimeo, TikTok, Instagram, Twitch and any video link
No coding — works on any website
The host’s share link vs. this generator
<video> tag.<video> tag that plays on your page/preview playerdl=0 opens Dropbox’s preview pageraw=1 in a <video> tag, so the file plays in placeloom.com/embed/… playerfast.wistia.net/embed/iframe/… playerMP4 or WebM file
The host’s share link
This generator
<video> tag that plays on your pageGoogle Drive
The host’s share link
This generator
/preview playerDropbox
The host’s share link
dl=0 opens Dropbox’s preview pageThis generator
raw=1 in a <video> tag, so the file plays in placeLoom
The host’s share link
This generator
loom.com/embed/… playerWistia
The host’s share link
This generator
fast.wistia.net/embed/iframe/… playerPlayer settings
The host’s share link
This generator
How to use the Video Embed Code generator
Paste a link
Use a direct .mp4 or .webm link, or a Google Drive, Dropbox, Loom or Wistia share link.
Pick options
Choose controls, autoplay, loop and an optional poster image.
Copy the code
Paste the HTML into an embed block. The generator uses the right format for each source.
HTML5 video attributes and link formats
src<source> elements inside the tag instead.src="/video/intro.mp4"<source type><source src="intro.webm" type="video/webm">controlscontrolsautoplaymuted. autoplay="false" doesn’t turn it off — remove the attribute.autoplay muted playsinlinemutedmutedplaysinlineplaysinlinelooploopposterposter="/img/cover.jpg"preloadnone, metadata (length and size only) or auto. The default differs between browsers.preload="metadata"controlslistnodownload, nofullscreen, noremoteplayback.controlslist="nodownload"<track>.vtt) file.<track kind="captions" src="captions.vtt" default>Dropbox raw=1…/intro.mp4?raw=1Google Drive /previewdrive.google.com/file/d/ID/previewLoom /embed/www.loom.com/embed/IDWistia iframefast.wistia.net/embed/iframe/IDsrc
What it does
<source> elements inside the tag instead.Example
src="/video/intro.mp4"<source type>
What it does
Example
<source src="intro.webm" type="video/webm">controls
What it does
Example
controlsautoplay
What it does
muted. autoplay="false" doesn’t turn it off — remove the attribute.Example
autoplay muted playsinlinemuted
What it does
Example
mutedplaysinline
What it does
Example
playsinlineloop
What it does
Example
loopposter
What it does
Example
poster="/img/cover.jpg"preload
What it does
none, metadata (length and size only) or auto. The default differs between browsers.Example
preload="metadata"controlslist
What it does
nodownload, nofullscreen, noremoteplayback.Example
controlslist="nodownload"<track>
What it does
.vtt) file.Example
<track kind="captions" src="captions.vtt" default>Dropbox raw=1
What it does
Example
…/intro.mp4?raw=1Google Drive /preview
What it does
Example
drive.google.com/file/d/ID/previewLoom /embed/
What it does
Example
www.loom.com/embed/IDWistia iframe
What it does
Example
fast.wistia.net/embed/iframe/IDSource: MDN: The Video Embed element
Embedded video not playing? Common fixes
An MP4 plays in some browsers but not others
The file is probably HEVC (H.265) — iPhones set to High Efficiency record in this format, and browser support for it depends on the device. Export it again as MP4 with H.264 video and AAC audio.
A Dropbox link downloads the file instead of playing it
Replace dl=0 or dl=1 in the link with raw=1. The generator does this for you.
Google Drive asks visitors for access
Change the file’s sharing to “Anyone with the link”. Google also notes that visitors who aren’t signed in may hit a playback limit, and that Drive video needs third-party cookies, so some browsers won’t play it.
Google Drive says the video is still processing
Drive needs time to prepare a new upload for playback, longer for big files. Wait and reload the page.
A Loom video asks viewers to sign in
In Loom, set the video’s privacy to “anyone with the link can view”, then copy the link again.
Autoplay doesn’t start
Browsers only allow autoplay when the video is muted. Keep muted and playsinline next to autoplay — Safari needs playsinline for autoplay.
A black box shows before the video plays
Add a poster image. Without one, the browser shows nothing until the first frame has loaded.
Where your video is hosted, and which link to paste
The generator works out the right code from the link. The link has to be the right one, and the video has to be visible to anyone who opens it.
.mp4 or .webm…/file/d/ID/view). The generator changes /view to /preview, Drive’s embeddable player.dl=0 to raw=1, so the file plays instead of opening the Dropbox preview page.loom.com/embed/… player.fast.wistia.net/embed/iframe/ID.Your own site or storage (MP4, WebM file)
Link to paste
.mp4 or .webmBefore you copy it
Google Drive
Link to paste
…/file/d/ID/view). The generator changes /view to /preview, Drive’s embeddable player.Before you copy it
Dropbox
Link to paste
dl=0 to raw=1, so the file plays instead of opening the Dropbox preview page.Before you copy it
Loom
Link to paste
loom.com/embed/… player.Before you copy it
Wistia
Link to paste
fast.wistia.net/embed/iframe/ID.Before you copy it
YouTube or Vimeo
Link to paste
Before you copy it
Choosing a format and compressing video for a website
MP4 with H.264 video and AAC audio plays in every major browser. If you upload only one file, make it this one.
WebM (AV1 or VP9 video with Opus audio) is an open, royalty-free format. Add it as an extra
<source>above the MP4 — browsers that can’t play it fall back to the MP4. Safari plays AV1 only on newer Apple devices with hardware support.iPhone videos recorded with the High Efficiency setting use HEVC (H.265), often as
.movfiles. Browser support for HEVC depends on the system and hardware, so convert these to H.264 MP4 before uploading. The iPhone’s Most Compatible camera setting records H.264 instead.Keep the file small. Trim the clip, export at the size it will be shown rather than at full camera resolution, and compress it. Every visitor downloads what they watch, and big files load slowly on mobile.
Add a poster image. It’s shown before playback; without it the player stays blank until the first frame loads.
Use
preload="metadata"so the browser loads only the length and size, not the whole video, until someone presses play.Add captions with a
<track>file (WebVTT), so the video works without sound.
Embed code vs. Elfsight Video Gallery
Videos per embed
Embed code
Video Gallery
Stays up to date
Embed code
Video Gallery
Mix sources
Embed code
Video Gallery
Layouts
Embed code
Video Gallery
Responsive design
Embed code
Video Gallery
Coding
Embed code
Video Gallery
Price
Embed code
Video Gallery