Step 1 Pick What to Embed
Choose YouTube, Vimeo, Google Maps or Any web page at the top left. Each one keeps its own link, so you can switch back and forth.
The preview loads the real player, so it needs the internet.
This is the real embed, loaded from the site itself.
<iframe
src="https://www.youtube-nocookie.com/embed/aqz-KE-bpKQ?start=30"
title="YouTube video player"
style="width: 100%; max-width: 800px; height: auto; aspect-ratio: 16 / 9; border: 0; border-radius: 12px;"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
referrerpolicy="strict-origin-when-cross-origin"
allowfullscreen
loading="lazy"></iframe>
An iframe is a window in your page that shows another web page. The YouTube player on a blog, the map on a shop's
contact page and the card form on a checkout page are almost always iframes. In HTML it's one tag,
<iframe>, and the page to show goes in its src:
<iframe
src="https://example.com"
title="Example Domain"
width="400"
height="200"></iframe> This generator writes that tag for you. Pick YouTube, Vimeo, Google Maps or any web page, paste a link, choose the size and options, and you get clean, escaped code plus a live preview of the real embed. Everything happens in your browser, and your last settings are remembered. If you want the full list of tags, see the HTML tags reference.
Five steps. The checks under the code tell you when something needs a second look.
Choose YouTube, Vimeo, Google Maps or Any web page at the top left. Each one keeps its own link, so you can switch back and forth.
For a video, paste the address from the browser bar or from the Share button. Normal links, youtu.be short links,
Shorts, live links and even a whole embed code all work. The video ID is pulled out and the right embed address
is built for you. A link with a start time (like &t=90) fills in the Start at box.
For a map, type an address or paste the code from Google Maps. If a link can't be used, you'll see why in red.
Responsive fills its column and keeps its shape (16:9 for normal videos, 9:16 for Shorts, 4:3, square or your own). Add a Max width so it doesn't get huge on wide screens. Fixed uses a width and height in pixels. Add a border or rounded corners if you like. Click Phone above the preview to see it on a small screen.
Keep Inline style for code you can paste anywhere, even into a blog editor's HTML box, or pick Class + <style> when you embed several frames that should look the same. Then press Copy code and paste it where the embed should go.
💡 The preview loads the real player from YouTube, Vimeo or Google, so it needs the internet. The code is ready to copy either way.
There are two easy ways. Both give you the same kind of code.
Here's what the code looks like for a video that starts at 0:30:
<iframe
width="560"
height="315"
src="https://www.youtube-nocookie.com/embed/aqz-KE-bpKQ?start=30"
title="YouTube video player"
style="border: 0;"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
referrerpolicy="strict-origin-when-cross-origin"
allowfullscreen
loading="lazy"></iframe>
The part after /embed/ is the video ID: the 11 characters after v= in a normal link
(youtube.com/watch?v=aqz-KE-bpKQ), after youtu.be/, or after
/shorts/. A normal watch link won't play inside an iframe, it has to be the /embed/ one.
| Add to the src | What it does |
|---|---|
?start=90 | Starts at 1:30. The time is in seconds. |
autoplay=1&mute=1 | Starts playing on its own. Browsers only allow that when the video is muted. |
loop=1&playlist=ID | Plays again at the end. A single video needs its own ID as the playlist, or it won't loop. |
controls=0 | Hides the player controls. People can still click the video to pause. |
cc_load_policy=1 | Turns captions on, when the video has them. |
rel=0 | Related videos at the end come only from the same channel. YouTube no longer lets you turn them off completely. |
Separate several settings with &: /embed/ID?start=90&mute=1. Inside an HTML
attribute the generator writes it as &, which is the fully correct form. Browsers read both.
An iframe with width="560" height="315" stays 560 pixels wide, so on a phone it sticks out of the
screen. Modern CSS fixes that in three lines: let it be as wide as its column, and tell the browser its shape with
aspect-ratio. The height follows by itself.
The code:
<style>
.video {
width: 100%;
max-width: 800px;
height: auto;
aspect-ratio: 16 / 9;
border: 0;
}
</style>
<iframe class="video" src="..." title="..."></iframe> You'll see (dark boxes stand in for videos):
aspect-ratio works in every current browser. Before it existed, people used the padding-bottom trick:
a wrapper with padding-bottom: 56.25% (which is 9 divided by 16) and the iframe stretched over it. You'll
still see it in older themes. It works too, it's just more code:
<style>
.video-wrap {
position: relative;
padding-bottom: 56.25%; /* 9 / 16 = 0.5625 */
height: 0;
}
.video-wrap iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border: 0;
}
</style>
<div class="video-wrap">
<iframe src="..." title="..."></iframe>
</div> Want to see how a whole page with embeds looks on a phone, a tablet and a laptop at once? Paste it into the Responsive HTML Viewer.
The official way is Google's own code. Open Google Maps, search for the place, click Share, open the Embed a map tab, pick a size and click Copy HTML. You get something like this:
<iframe
src="https://www.google.com/maps/embed?pb=!1m18!1m12..."
width="600"
height="450"
style="border:0;"
allowfullscreen=""
loading="lazy"
referrerpolicy="no-referrer-when-downgrade"></iframe> Paste it here under Google Maps, then Google's embed code, and the generator checks it's really a Google Maps address and lets you make it responsive and add a title (Google's code has none).
The quick way is to type an address. That uses an older Google Maps address with
output=embed on the end. It works today and needs no account, but Google doesn't document it, so it
could stop working one day. Use the official code for anything important.
<iframe
src="https://maps.google.com/maps?q=Eiffel%20Tower%2C%20Paris&z=14&output=embed"
title="Map of Eiffel Tower, Paris"
style="width: 100%; height: auto; aspect-ratio: 4 / 3; border: 0;"
loading="lazy"></iframe> A normal Google Maps link (the one in your browser bar, or a maps.app.goo.gl short link) won't work as an iframe src: Google blocks it. It has to be the embed address.
Any https:// page can go in an iframe's src, but the page gets the final say. Many sites send an
X-Frame-Options: DENY header or a Content-Security-Policy: frame-ancestors rule that tells
browsers not to show them inside other sites. Google, Facebook, most banks and many news sites do it, to stop
tricks where an invisible frame catches your clicks (called clickjacking).
When that happens the frame stays blank or shows a "refused to connect" message. That's the other site's choice,
not a mistake in your code, and nothing on your side can change it. Link to the page instead, or ask the site if it
has an official embed (like YouTube's /embed/ addresses).
Two more things to know: a page served over https:// won't show an http:// page inside it (browsers block that as "mixed content"), and the frame only shows what the other site shows, so it can change at any time.
| Attribute | What it does |
|---|---|
src | The address of the page to show. For YouTube it is https://www.youtube.com/embed/ plus the video ID, not the normal watch link. |
title | A short name for the frame, like "YouTube video player". Screen readers read it out, so every iframe should have one. |
width / height | The size in pixels (no "px"). Leave them out when you size the frame with CSS for a responsive embed. |
loading="lazy" | Waits to load the frame until someone scrolls near it. Pages load faster, especially with videos further down. |
allow | Turns on browser features inside the frame: autoplay, fullscreen, picture-in-picture, encrypted-media (needed for most video players) and others. |
allowfullscreen | Lets the full screen button in a video player or map work. |
sandbox | Takes rights away from the page inside: scripts, forms, pop-ups and more. Flags like allow-scripts give single rights back. |
referrerpolicy | How much of your page's address the embedded site sees. YouTube and Vimeo use strict-origin-when-cross-origin: they see your site's name, not the full page path. |
style / class | The CSS: border, corners and the responsive size. frameborder="0" is the old way to remove the border; use border: 0 in CSS now. |
A page in an iframe runs in its own box: it can't read your page, your cookies or what your visitors type. It can still run its own scripts, open pop-ups and show its own forms. So the first rule is simple: only embed sites you trust.
For anything else, add sandbox. An empty sandbox="" turns off scripts, forms, pop-ups
and more. Then you give back only what the page needs, one flag at a time:
<!-- Nothing allowed: no scripts, forms or pop-ups -->
<iframe src="https://example.com" title="Example" sandbox=""></iframe>
<!-- Scripts and new tabs, but no cookies and no forms -->
<iframe
src="https://example.com"
title="Example"
sandbox="allow-scripts allow-popups allow-popups-to-escape-sandbox"></iframe>
One combination to avoid for pages you don't trust: allow-scripts together with
allow-same-origin. With both, the page runs as itself with its own cookies and storage, so the
sandbox protects very little. And if the framed page comes from your own site, its scripts can simply remove the
sandbox. The generator warns you when both are ticked. (Our own preview never uses allow-same-origin, which is why
some pages can look a little different in it.)
Every embed loads something from another company, and that company can see the visit. You can cut that down:
www.youtube-nocookie.com/embed/ (privacy mode, on by default here). YouTube stores no cookies until someone presses play.dnt=1 (Do not track, on by default here). Vimeo then sets no tracking cookies.loading="lazy" means nothing loads until someone scrolls near the frame.If your site has a privacy policy, mention the services you embed. Want your own page to look good when it's shared? The Meta Tag Generator makes the title, description and share image tags.
Want to try your embed on a full page? Paste the code into the HTML Viewer or the HTML Editor and see it next to the rest of your HTML.
An iframe (inline frame) is a box on your page that shows another web page inside it. The <iframe> tag gets the address in its src attribute: <iframe src="https://www.youtube-nocookie.com/embed/aqz-KE-bpKQ" title="YouTube video player"></iframe>. YouTube videos, Google Maps and payment forms on other sites are almost always iframes.
Paste the video link into the generator above (a watch?v= link, a youtu.be link or a Shorts link all work) and copy the code. Or, on YouTube, click Share under the video, then Embed, and copy the code there. Either way you get an <iframe> whose src is https://www.youtube.com/embed/ (or youtube-nocookie.com/embed/ in privacy mode) followed by the 11-character video ID. Paste it into your HTML where the video should go.
Give it width: 100% and the shape of the video with aspect-ratio, and leave the height to the browser: style="width: 100%; height: auto; aspect-ratio: 16 / 9; border: 0;". It then fills its column and keeps its shape on any screen. Add max-width (like 800px) so it doesn't get huge on wide screens. The old padding-bottom: 56.25% wrapper trick does the same thing for very old browsers.
The site you're trying to show doesn't allow it. Sites can send an X-Frame-Options header or a Content-Security-Policy frame-ancestors rule that tells browsers not to show them inside other sites. Google, Facebook, most banks and many news sites do this to protect their users from tricks like clickjacking. Your code is fine, and there's no way around it from your side. Link to the page instead.
The official way: open Google Maps, find the place, click Share, then the Embed a map tab, pick a size and click Copy HTML. Paste that code into your page (or into the generator to change its size and make it responsive). A quicker unofficial way is an address like https://maps.google.com/maps?q=Eiffel%20Tower&output=embed. It works today, but Google doesn't document it, so it could change.
It's YouTube's privacy-enhanced mode. The video is the same, but YouTube doesn't store cookies on your visitors' browsers just because the page loaded; that starts only when someone presses play. Swap www.youtube.com/embed/ for www.youtube-nocookie.com/embed/ in the src. The generator uses it by default.
Browsers block videos that start on their own with sound. Add mute=1 next to autoplay=1 in a YouTube src (or muted=1 for Vimeo), and the allow attribute must include autoplay. Even then, some browsers and phones in power-saving mode may wait for a tap. The generator turns mute on for you when you switch on Autoplay.
sandbox takes rights away from the page inside the frame. An empty sandbox="" blocks scripts, forms, pop-ups and more. Each flag you add gives one right back, like allow-scripts or allow-forms. Use it for pages you don't control. Don't combine allow-scripts with allow-same-origin for pages you don't trust: together they let the page run as itself with its cookies, and a page from your own site could even remove its own sandbox.