iFrame Generator
Preview blank or “refused to connect”? The site doesn’t let other sites show it in a frame (its X-Frame-Options or Content-Security-Policy header), and only its owner can change that. Learn more
<div style="position:relative;width:100%;aspect-ratio:16 / 9;"> <iframe src="https://example.com/" title="example.com" loading="lazy" style="position:absolute;inset:0;width:100%;height:100%;border:0;"></iframe> </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/iframe-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.
Embedding forms, reviews or feeds? Elfsight widgets do it without iframes and match your site’s design. See Elfsight widgets →
iFrame Generator vs writing the iframe by hand
title so the frame is labeled for assistive technology.allow-* tokens yourself and look up what each one unlocks.X-Frame-Options and frame-ancestors headers before you copy the code.Attributes
Writing the iframe by hand
This generator
Accessible title
Writing the iframe by hand
This generator
title so the frame is labeled for assistive technology.Sandbox
Writing the iframe by hand
allow-* tokens yourself and look up what each one unlocks.This generator
Responsive size
Writing the iframe by hand
This generator
Can this page be embedded?
Writing the iframe by hand
This generator
X-Frame-Options and frame-ancestors headers before you copy the code.Video and form links
Writing the iframe by hand
This generator
iframe attributes reference
srchttps:// address. On an HTTPS site, browsers block frames that load over plain http://.titlewidth / heightwidth: 100% and aspect-ratio) instead of fixed numbers.loadingeager (default), lazylazy waits until the frame is close to the visible area, which speeds up the initial page load. Good for frames lower on the page.allowfullscreen; autoplayallowfullscreenallow="fullscreen"; many embed codes include both.referrerpolicyno-referrer, origin, strict-origin-when-cross-origin (default) and othersunsafe-url: it sends the full address, even to insecure sites.sandboxallow-* token lifts one restriction.allow-scripts, allow-forms, allow-popupsallow-scripts and allow-same-origin for a page from your own site: together they let the page remove the sandbox.src
What it does
Values
Notes
https:// address. On an HTTPS site, browsers block frames that load over plain http://.title
What it does
Values
Notes
width / height
What it does
Values
Notes
width: 100% and aspect-ratio) instead of fixed numbers.loading
What it does
Values
eager (default), lazyNotes
lazy waits until the frame is close to the visible area, which speeds up the initial page load. Good for frames lower on the page.allow
What it does
Values
fullscreen; autoplayNotes
allowfullscreen
What it does
Values
Notes
allow="fullscreen"; many embed codes include both.referrerpolicy
What it does
Values
no-referrer, origin, strict-origin-when-cross-origin (default) and othersNotes
unsafe-url: it sends the full address, even to insecure sites.sandbox
What it does
allow-* token lifts one restriction.Values
allow-scripts, allow-forms, allow-popupsNotes
allow-scripts and allow-same-origin for a page from your own site: together they let the page remove the sandbox.Why a site doesn’t open in an iframe
The frame is empty or shows “refused to connect”.
The site sends an X-Frame-Options header. DENY blocks all framing; SAMEORIGIN allows it only on the site’s own pages. The site has forbidden embedding, and this can’t be bypassed from your side. Link to the page instead, or ask the site owner whether they offer an embed.
The site’s security policy blocks the frame.
The site sends Content-Security-Policy with frame-ancestors, which lists the sites allowed to embed it ('none' means nobody). When it’s present, browsers follow it instead of X-Frame-Options. Only the site owner can add your domain to the list.
The frame loads on its own but not on your HTTPS site.
The src starts with http://. Browsers block insecure frames on secure pages and don’t upgrade them automatically. Change the address to https://; if the site has no HTTPS version, it can’t be embedded on a secure page.
A YouTube link shows an error instead of the video.
Regular YouTube watch pages forbid framing. Use the video’s embed address (youtube.com/embed/…) or the dedicated YouTube generator.
The page loads, but buttons, forms or links inside it do nothing.
The sandbox attribute is blocking them. Add only the tokens you need: allow-scripts for interactive content, allow-forms to submit forms, allow-popups for links that open a new tab.
Video won’t go fullscreen, or the camera or microphone doesn’t work.
These features must be granted in the allow attribute, e.g. allow="fullscreen; camera; microphone".
Your site builder removes the code after saving.
Some editors strip iframes from regular text blocks. Paste the code into a custom HTML or embed block.
How to create an iframe
Enter the page address
Paste the URL of the page you want to show.
Set size and behavior
Choose the size, keep it responsive and allow scrolling or fullscreen if needed.
Check the preview
Some sites don’t allow being shown in a frame — the preview shows it right away.
Copy the code
Paste the code into an HTML block on your site.