Responsive Iframe Embed Code Generator

Generate clean, responsive, secure iframe embed codes with live preview. Auto-detect YouTube, Vimeo, Google Maps, Spotify, Figma & 15+ platforms. Includes sandbox security, lazy loading, aspect-ratio calculator & X-Frame-Options checker.

Instant Live Preview: Code and preview update as you type — no form submit, no page reload. Paste your URL and your iframe is ready in under 3 seconds.
15+
Auto-detected Platforms
4
Sandbox Modes
100%
Real-Time Preview
Live Preview
Code Ready

Enter a URL to see live preview

Generated HTML

    

01What is an Iframe Embed? A Complete Technical Primer

An inline frame (<iframe>) is an HTML element that renders another HTML document within the current page, inside a nested browsing context. It is the web's universal mechanism for embedding third-party content — from YouTube videos and Google Maps to Spotify players, Figma designs, interactive data dashboards, and full web applications — without hosting those assets on your own server.

Iframes were standardised in HTML 4.0 (1997) as part of Internet Explorer's proprietary extensions, later adopted by all browsers, and have remained the go-to embedding primitive for over two decades. In 2014, the HTML5 spec formalized the sandbox, allow, and srcdoc attributes, transforming iframes from a liability into a robust, security-configurable component.

Today, virtually every SaaS product with an "embed" button generates an iframe tag. When you click "Share → Embed" on YouTube, Vimeo, Google Maps, Spotify, Typeform, Airtable, Calendly, or Figma, you receive an iframe code snippet that embeds that service's renderer inside your webpage. This tool auto-detects those platforms and converts standard sharing URLs into the correct embed format automatically.

Key concepts: An iframe creates a separate browsing context with its own DOM, JavaScript scope, and CSS. The embedded page cannot access the parent page's JavaScript variables (due to the same-origin policy), and the parent page cannot read the iframe's DOM unless both pages share the same origin.

02Responsive Iframe — The CSS Padding-Hack Explained

The core problem with standard iframes is their rigidity. A naive implementation like <iframe width="560" height="315"> specifies fixed pixel dimensions. On a 375px-wide mobile screen, this iframe bursts out of its container, forcing horizontal scroll — a catastrophic UX failure that triggers mobile ranking penalties in Google's Core Web Vitals evaluation.

The padding-top percentage trick is the industry-standard solution. Here is how it works step by step:

  1. Wrap the iframe in a <div> with position: relative; width: 100%; overflow: hidden;. This div expands to 100% of its parent container's width.
  2. Set padding-top on the wrapper as a percentage. In CSS, padding-top expressed as a percentage is always calculated based on the element's width — not height. This creates a height-from-width relationship.
  3. For 16:9 aspect ratio: padding-top = (9 ÷ 16) × 100 = 56.25%. The wrapper is always 56.25% as tall as it is wide — perfectly maintaining the 16:9 ratio at any screen size.
  4. Set the iframe to position: absolute; top: 0; left: 0; width: 100%; height: 100%; so it fills the wrapper exactly.
Aspect RatioUse Casepadding-top FormulaComputed %
16:9YouTube, Vimeo, Presentations9 ÷ 16 × 10056.25%
4:3Classic video, legacy content3 ÷ 4 × 10075.00%
1:1Spotify, Instagram widgets1 ÷ 1 × 100100.00%
9:16YouTube Shorts, TikTok, vertical video16 ÷ 9 × 100177.78%
21:9Cinematic ultrawide video9 ÷ 21 × 10042.86%
2:1Panorama banners, maps1 ÷ 2 × 10050.00%

This tool generates the complete responsive wrapper HTML automatically when you toggle "Responsive Mode." Our generated code includes the correct padding-top percentage for your chosen aspect ratio, with no additional CSS or JavaScript dependencies required.

03Platform-by-Platform Embed URL Guide (15+ Services)

One of the most common developer frustrations with iframe embeds is that the URL shown in a browser's address bar is almost never the correct URL to use as the iframe src. Every platform provides a separate "embed URL" format. This tool auto-detects and converts the most common platforms.

PlatformBrowser URL PatternCorrect Embed URL FormatAuto-detected?
YouTubeyoutube.com/watch?v=IDyoutube.com/embed/ID?rel=0✓ Yes
YouTube Shortsyoutube.com/shorts/IDyoutube.com/embed/ID✓ Yes
Vimeovimeo.com/12345678player.vimeo.com/video/12345678✓ Yes
Spotify Trackopen.spotify.com/track/IDopen.spotify.com/embed/track/ID✓ Yes
Spotify Playlistopen.spotify.com/playlist/IDopen.spotify.com/embed/playlist/ID✓ Yes
Google MapsGet embed URL from Share → Embed buttongoogle.com/maps/embed?pb=…✓ Yes
Figmafigma.com/file/HASH/Namefigma.com/embed?embed_host=share&url=…✓ Yes
CodePencodepen.io/user/pen/IDcodepen.io/user/embed/ID?theme-id=dark✓ Yes
Airtableairtable.com/embed/shrIDSame URL (use Share → Embed from Airtable)✓ Yes
Typeformyourname.typeform.com/to/IDSame URL + ?typeform-embed=embed-fullpage✓ Yes
SoundCloudsoundcloud.com/artist/trackw.soundcloud.com/player/?url=…✓ Yes
Google Slidesdocs.google.com/presentation/d/ID/pubSame /pub URL + &start=false✓ Yes
PDF Fileshttps://example.com/file.pdfDirect PDF URL (browser renders inline)✓ Yes
Calendlycalendly.com/usernameDirect URL (set height: 700px)✓ Yes
Instagram Postinstagram.com/p/ID/Use oEmbed API endpoint (server-side)⚠ Manual
Twitter/X embeds note: Twitter discontinued public iframe embedding. Use their official JavaScript widget (blockquote class="twitter-tweet" + their embed.js script) instead of an iframe for tweet embeds. Our tool supports custom URLs for all other platforms.

04Iframe Security: Sandbox, CSP & Permissions Policy

An unsandboxed iframe runs the embedded page's JavaScript with full access to browser APIs — including the ability to redirect the parent window (top.location.href = '…'), open popups, access device APIs (with user permission), and attempt clickjacking attacks. For untrusted third-party embeds, this is a significant security risk.

The sandbox Attribute

Adding sandbox to an iframe creates an isolated security context. Without any flags, sandbox disables everything — scripts, form submission, popups, and even the ability to navigate. You then whitelist only the capabilities the embed needs:

Sandbox FlagWhat It AllowsRisk Level Without It
allow-scriptsRun JavaScript inside the iframe.Most widgets completely break. Required for YouTube, Vimeo, Spotify, Maps.
allow-same-originAccess own cookies, localStorage, and session state.Required for logged-in state persistence (e.g., YouTube "watch later" saves).
allow-formsSubmit HTML form elements.Use only for survey/form embeds (Typeform, Google Forms, Calendly).
allow-popupsOpen new browser tabs via window.open().Rarely needed. High risk — allows ad redirect chains.
allow-top-navigation-by-user-activationRedirect parent window on user click only.Much safer than allow-top-navigation which allows silent redirects.

Permissions Policy (formerly Feature Policy)

The allow attribute combined with the Permissions-Policy HTTP header lets you restrict which browser features the iframe can access. You can deny camera, microphone, geolocation, payment, and autoplay access entirely, regardless of what the embedded page requests:

<iframe allow="camera=(); microphone=(); geolocation=()">

This is especially important when embedding marketing widgets, analytics dashboards, or A/B testing tools that may include tracking pixels or device fingerprinting scripts.

Security recommendation: For any third-party embed you don't fully control or audit, enable sandbox="allow-scripts allow-same-origin" as a minimum. This dramatically reduces the attack surface while keeping most widgets functional. Add additional flags only as needed.

05Lazy Loading Iframes & Core Web Vitals Impact

An embedded YouTube iframe (unsandboxed, unoptimized) loads approximately 400–600KB of JavaScript the instant the page loads, even if the video is at the bottom of the page and the user never scrolls to it. Three such iframes on a single page can add 1.5–2 seconds to the Time to Interactive (TTI) metric — a Core Web Vitals signal with direct Google Search ranking implications.

The loading="lazy" attribute (natively supported in all modern browsers since 2020) instructs the browser to defer loading the iframe until the user scrolls within a calculated "lazy load threshold" — approximately 1,250–2,500px from the viewport edge, depending on connection speed.

OptimizationPerformance ImpactWhen to Apply
loading="lazy"Defers iframe network requests until user nears it. Reduces initial page weight by 300–600KB for video iframes.All below-fold iframes. Enable by default in this tool.
Responsive CSS wrapperEliminates CLS (Cumulative Layout Shift) from iframe resizing. CLS score directly impacts Google rankings.All iframes. Especially critical for video players.
Lite-YouTube facadeReplace YouTube iframe with a thumbnail image, inject real player only on click. Saves 500KB on load.When maximum LCP optimization is the goal.
Intersection ObserverJavaScript-based lazy loading for browsers without native support. 99%+ browser coverage now means this is rarely needed.Legacy browser support only.
Important exception: Do NOT use loading="lazy" on iframes that are visible in the initial viewport (above the fold). Lazy loading an above-fold iframe can delay its appearance and worsen your LCP score. Only apply lazy loading to embeds that require scrolling to reach.

06X-Frame-Options: Why Some Websites Can't Be Embedded

If you've tried to embed a major website (Google.com, Facebook.com, your banking site) and got a blank iframe or an error, you've encountered the X-Frame-Options HTTP response header. When a server sends this header, the browser refuses to render the page inside any iframe.

Header ValueBrowser BehaviorCommon Use
X-Frame-Options: DENYBlocks embedding from any origin — including the page's own domain.Login pages, payment processors, banking portals.
X-Frame-Options: SAMEORIGINAllows embedding only from the exact same domain.Internal dashboards, CMS admin panels.
X-Frame-Options: ALLOW-FROM uriAllows embedding from one specific origin (deprecated, use CSP instead).Whitelisted partner embeds.
Content-Security-Policy: frame-ancestors 'self' example.comModern replacement for X-Frame-Options. More flexible — allows multiple origins.SaaS applications with selective embedding.

There is no client-side workaround for X-Frame-Options. It is enforced by the browser as a security measure to prevent clickjacking attacks — where a malicious site overlays an invisible iframe of your banking login page on top of a legitimate-looking button, capturing your credentials when you click.

If you control the target server: Add the header Content-Security-Policy: frame-ancestors 'self' https://yoursite.com to explicitly allow your site to embed the page. This is far more secure and flexible than the deprecated X-Frame-Options: ALLOW-FROM.

07Iframe Accessibility: Screen Readers, ARIA & Keyboard Navigation

An unlabeled iframe is an accessibility failure. When a screen reader (NVDA, JAWS, VoiceOver) encounters an iframe with no title attribute, it announces something like "frame" or the iframe's URL — providing zero context about what the embedded content is or whether the user should enter it. For WCAG 2.1 Level A compliance (required for most government, educational, and public-sector websites), every iframe must have a meaningful title attribute.

  • Use descriptive titles: title="YouTube video: How to make sourdough bread" is excellent. title="Video" is insufficient. title="iframe" is a failure.
  • Keyboard focus order: Iframes participate in the page's tab order. Screen reader users will navigate into the iframe when tabbing. Ensure the embedded content itself has proper focus management (most reputable embeds from YouTube, Vimeo, Spotify handle this correctly).
  • Hidden from assistive technology: If an iframe contains purely decorative or presentational content, use aria-hidden="true" and tabindex="-1" to exclude it from the tab order and screen reader announcement.
  • Loading indicators: For iframes with slow-loading content, consider adding a aria-label on the wrapper div that says "Loading [content name]" while the iframe loads.
This tool enforces accessibility by default: The "Accessibility Title" field in the Output tab is required and defaults to "Embedded Content." Change it to a specific description every time — it takes 5 seconds and directly improves your WCAG compliance score, which affects legal accessibility requirements in many jurisdictions.

08Do Iframes Hurt SEO? Google's Exact Position

The answer is nuanced and depends entirely on what you're embedding. Google's official stance (confirmed by John Mueller in multiple Search Central Hangouts) is: "Googlebot can render and index iframe content. We treat the iframe's URL as a separate page, and the content belongs to that URL's origin."

In practice, this means:

  • Iframe content is NOT counted as your content. A YouTube iframe on your page does not give your page credit for the video's keywords. The video's content belongs to YouTube.com from Google's perspective.
  • Iframes can hurt performance metrics. If your iframe loads heavy JavaScript bundles (a YouTube embed can add 500KB of blocking JS), this degrades your LCP, TTI, and TBT Core Web Vitals scores — which DO affect rankings. Use loading="lazy" religiously.
  • Iframes can cause CLS. An iframe without a fixed height or aspect ratio wrapper will resize as its content loads, causing Layout Shift — a Core Web Vitals violation that Google's ranking algorithm penalizes. The responsive wrapper this tool generates eliminates CLS entirely.
  • Iframe src URLs are crawled separately. Google may follow and index the URL in your iframe's src attribute. If you embed private or sensitive documents, consider using X-Robots-Tag: noindex on the embedded resource.
Best SEO practice: Surround your iframe with meaningful text content. Write a paragraph above and below describing what the embed contains. This gives Google contextual signals about the embed topic, helps users who can't see the iframe (blind users, corporate firewalls blocking the embed origin), and provides textual SEO value that the iframe itself cannot contribute.

09PostMessage API: Communicating Between Iframe & Parent Window

The same-origin policy prevents an iframe and its parent page from directly accessing each other's JavaScript variables when they are on different domains. The window.postMessage() API is the secure, browser-native solution for bidirectional communication between a parent page and embedded iframes, regardless of origin.

Here is the complete implementation pattern:

In the parent page (sender):

document.getElementById('my-iframe').contentWindow.postMessage({action:'updateTheme', theme:'dark'}, 'https://trusted-embed.com');

In the embedded page (receiver):

window.addEventListener('message', function(event) {
if (event.origin !== 'https://yoursite.com') return; // Always verify origin!
console.log(event.data); // {action:'updateTheme', theme:'dark'}
});

PostMessage powers critical embedded app experiences — Stripe's payment form communicates card validity back to the parent checkout page, Calendly notifies the parent when a booking is confirmed, and Figma's embed API allows parent apps to receive selection-change events from the embedded design tool.

Security warning: Always validate event.origin in your postMessage receiver. Failing to do so creates an open message injection vulnerability — any website could postMessage to your iframe and trigger actions. Use exact string comparison: if (event.origin !== 'https://yoursite.com') return;

10ZeonTools vs Other Iframe Embed Code Generators

The market for iframe embed generators ranges from basic HTML forms to premium developer tools. Here is an honest feature comparison with the most widely used alternatives:

Feature
ZeonTools (Free)
IFrameGenerator.net
HTML Online Tools
Live iframe preview
✓ Real-time
✗ None
Static only
Auto-detect platform (YouTube, Maps, Spotify…)
✓ 14 platforms
✗ None
✗ None
Responsive padding-hack mode
✓ 7 ratios
Basic only
✗ None
Sandbox security flags
✓ 5 flags
✗ None
✗ None
Permissions Policy (Feature Policy)
✓ Yes
✗ None
✗ None
Lazy loading toggle
✓ Default on
✗ None
✗ None
Referrer policy
✓ 3 options
✗ None
✗ None
Syntax-highlighted output
✓ Color coded
Plain text
Plain text
Figure + figcaption semantic wrap
✓ Yes
✗ None
✗ None
WCAG accessibility title field
✓ Enforced
✗ None
✗ None
URL validation with error messages
✓ Real-time
✗ None
✗ None
Cost
Free Forever
Free
Free

FAQFrequently Asked Questions

Why does my iframe show a blank white page or 'Connection Refused' error?

The most common cause is the X-Frame-Options HTTP response header. When a website sends X-Frame-Options: DENY or SAMEORIGIN, browsers refuse to render that site inside any iframe. High-security sites like Google.com, Facebook.com, Twitter.com, LinkedIn, and all banking/payment platforms use this header specifically to prevent clickjacking attacks.

There is no client-side workaround — it is enforced by the browser as a security measure. If you control the target server, add the header: Content-Security-Policy: frame-ancestors 'self' https://yoursite.com to selectively allow your domain to embed the page.

What is the correct embed URL format for YouTube?

The standard YouTube watch URL (youtube.com/watch?v=VIDEO_ID) cannot be used directly as an iframe src. You must convert it to the embed format:

Watch URL: https://www.youtube.com/watch?v=dQw4w9WgXcQ
Embed URL: https://www.youtube.com/embed/dQw4w9WgXcQ

Optional parameters: add ?rel=0 to prevent suggested videos from other channels after playback, ?autoplay=1 for autoplay (requires muted=1 on most browsers), and ?start=30 to begin at 30 seconds.

This tool automatically detects standard YouTube watch URLs and converts them to the correct embed format.

How do I make an iframe responsive without a fixed height?

Use the CSS padding-top percentage hack. The technique works because CSS padding percentages are calculated from the element's width, not its height — allowing you to create a height-follows-width relationship:

1. Wrap the iframe in a div with position:relative; width:100%; overflow:hidden;
2. Set padding-top as a percentage = (height ÷ width) × 100
For 16:9 video: padding-top: 56.25%
3. Set the iframe to position:absolute; top:0; left:0; width:100%; height:100%;

The wrapper always maintains the exact aspect ratio at any screen width. This eliminates Cumulative Layout Shift (CLS), a Core Web Vitals metric that directly affects Google Search rankings. Toggle 'Responsive Mode' in this tool to generate this code automatically.

What does the sandbox attribute do and should I use it?

The sandbox attribute applies a security lockdown to the iframe, treating the embedded content as untrusted. Without any flags, sandbox disables everything: scripts, forms, popups, pointer lock, and top-level navigation.

You selectively enable permissions using flags:
• allow-scripts — required for YouTube, Maps, Spotify, most interactive widgets
• allow-same-origin — required for the iframe to access its own cookies/session state
• allow-forms — required for survey/booking embeds (Typeform, Calendly)
• allow-popups — risky, only use if the widget explicitly needs it

Recommendation: For any third-party embed you don't fully audit, use sandbox='allow-scripts allow-same-origin' as a baseline. This blocks the most dangerous behaviors (top-level navigation redirects, pointer lock) while keeping most widgets functional.

Does adding an iframe slow down my website?

Yes — significantly, if not optimized. A standard YouTube iframe loads approximately 400–600KB of JavaScript and makes 10–20 network requests as soon as the page loads, even if the video is at the bottom. Three such iframes can add 1–2 seconds to your Time to Interactive (TTI) score.

The solution is loading='lazy'. This defers all iframe network requests until the user scrolls within ~1,500px of the iframe. For above-fold iframes that are immediately visible, do not use lazy loading — it will delay their appearance and worsen your Largest Contentful Paint (LCP) score.

For YouTube specifically, consider a 'lite embed' facade: display a thumbnail image, and replace it with the real iframe only when the user clicks play. This saves 500KB on initial load.

Can I embed a Google Drive document or spreadsheet?

Yes. To get the embed URL for a Google Drive document:

1. Open the document in Google Docs, Sheets, or Slides
2. Click File → Share → Publish to web
3. Click Embed tab
4. Copy the src URL from the provided iframe code

Do not use the regular sharing URL (docs.google.com/document/d/ID/edit) as the iframe src — it requires login and won't display publicly. The /pub URL (docs.google.com/document/d/ID/pub) is the correct embeddable format. Set height to 600px for documents, or use responsive mode with 4:3 ratio for spreadsheets.

What is the difference between allow='fullscreen' and allowfullscreen?

Both serve the same purpose — enabling the fullscreen button in video players — but they represent different generations of the HTML spec:

allowfullscreen is the original HTML5 boolean attribute. When present, it enables the Fullscreen API for the iframe's content.

allow='fullscreen' is the modern Feature Policy / Permissions Policy syntax introduced in 2019. It's more flexible because it can specify exactly which features are allowed and optionally restrict them to specific origins.

For maximum browser compatibility, include both:
<iframe allowfullscreen allow='fullscreen'>...

This tool adds both when you enable the 'Allow Fullscreen' toggle.

Why can't I embed Instagram or Twitter/X posts using a simple iframe src?

Both platforms block direct iframe embedding via X-Frame-Options headers. They provide their own official embed mechanisms instead:

Twitter/X: Use the official embed blockquote + script approach. Visit publish.twitter.com, enter the tweet URL, and copy the code. It generates a <blockquote class='twitter-tweet'> element plus a <script> tag that loads Twitter's widget.js to render it.

Instagram: Use their oEmbed API endpoint. Make a server-side request to https://graph.facebook.com/v18.0/instagram_oembed?url=POST_URL&access_token=YOUR_TOKEN to get the embed HTML. A client-side JavaScript approach is also available via Instagram's embed.js script.

For both platforms, the official embed mechanism handles their anti-embedding policy correctly.

How does Google handle iframe content for SEO?

Google's John Mueller has confirmed that Googlebot renders iframe content and indexes it separately, attributing it to the iframe's src URL's origin — not your page. This means:

• YouTube video content embedded on your page is indexed as YouTube's content, not yours
• Embedded blog posts from other domains count toward that domain's SEO, not yours
• Iframes do not pass PageRank or link equity from your page to the embedded origin

Iframes can hurt your SEO indirectly through performance — slow-loading iframes increase TTI and worsen Core Web Vitals scores, which Google uses as ranking signals. Always use loading='lazy' for below-fold iframes, and wrap all iframes in a responsive container to eliminate CLS score penalties.

What is the Permissions Policy (formerly Feature Policy) allow attribute?

The allow attribute on an iframe controls which browser features the embedded page can access, independent of what the page's JavaScript requests. It implements the Permissions Policy specification.

Examples:
• allow='camera=()' — prevents the embed from accessing the camera, even if the user grants the site camera permission
• allow='microphone=(); geolocation=()' — blocks microphone and GPS access
• allow='autoplay=*' — explicitly allows autoplay (often required for video players)
• allow='payment' — required for payment form embeds (Stripe)

This is more powerful than sandbox for granular feature control. You can deny specific dangerous features while leaving the general allow-scripts permission intact.

Can I use an iframe to embed content from my own website on another page?

Yes — same-origin iframes (where parent and child share the exact same protocol, hostname, and port) have full mutual JavaScript access via contentWindow and contentDocument. There are no same-origin policy restrictions.

Common same-site uses include:
• Embedding a payment form on a landing page without navigating away
• Displaying a preview of a different page within an admin panel
• Creating a 'magazine layout' with side-by-side article readers

For cross-domain self-embeds (e.g., embedding your app on a marketing site hosted on a different subdomain), use the postMessage API for communication between the two contexts.

How do I embed a PDF file so users can read it without downloading?

Modern browsers include a built-in PDF viewer that renders PDF files directly inside iframes. Simply set the iframe src to the direct URL of a publicly accessible PDF file:

<iframe src='https://example.com/document.pdf' width='100%' height='600px' title='Annual Report PDF'></iframe>

Important considerations:
• The PDF must be served with CORS headers or from the same origin as your page
• On mobile, browsers often redirect PDF iframes to the device's native PDF viewer rather than rendering inline — provide a fallback download link
• Google Drive PDF links (drive.google.com/file/d/ID/preview) use the Google Docs PDF viewer and work more reliably across devices than direct PDF embeds
• Maximum file size for smooth inline rendering is approximately 10MB; larger PDFs should use server-side rendering or a dedicated PDF viewer library like PDF.js

What is the srcdoc attribute and when should I use it instead of src?

The srcdoc attribute allows you to write the entire HTML content of the iframe inline in the attribute value, rather than loading it from a URL:

<iframe srcdoc='<h1>Hello World</h1><p>This is inline iframe content</p>'></iframe>

Use cases for srcdoc:
• Email HTML preview panes (showing an email's HTML in isolation without external requests)
• Code playground output panels (CodePen-style tool where you write HTML that renders live)
• Sanitized user-generated content display (prevent XSS by rendering HTML in an isolated context)
• Offline-capable embedded content that doesn't require a network request

When sandbox is combined with srcdoc and no allow-same-origin flag is set, the iframe gets a unique null origin — meaning it has no access to parent cookies, localStorage, or external resources, creating an extremely isolated sandbox.

How do I prevent my iframe from creating a scrollbar?

Iframe scrollbars appear when the embedded content is larger than the iframe's dimensions. There are several approaches:

1. Set scrolling='no' attribute (deprecated HTML4 method, still works in most browsers):
<iframe scrolling='no'>

2. Use CSS on the iframe element:
iframe { overflow: hidden; }

3. Combine both for maximum compatibility:
<iframe scrolling='no' style='overflow:hidden;'>

4. Hide overflow on the embedded content (requires same-origin or cooperation from the embedded page):
The embedded page's body needs: body { overflow: hidden; }

Note: For responsive iframes using the padding-top wrapper technique, scrollbars typically don't appear because the iframe matches the content's natural dimensions. The scrollbar issue mainly affects fixed-dimension iframes where content overflows.

Can I print the contents of an iframe?

Printing iframe contents is browser-dependent and often problematic:

On same-origin iframes: You can trigger print on the iframe's contentWindow directly:
document.getElementById('my-iframe').contentWindow.print();
This prints only the iframe content, not the parent page.

On cross-origin iframes: Direct JavaScript access is blocked by the same-origin policy. The iframe's printing behavior is controlled entirely by the embedded page.

For the full page print (parent + iframes): Modern browsers include iframe content when printing the full page if the iframe is same-origin. Cross-origin iframes may appear as blank areas in the printed output, depending on the browser and the embedded site's server configuration.

Best practice: If printable content is essential, don't embed it in a cross-origin iframe — link to it instead, or reproduce the content directly in your page.

Rate Responsive Iframe Embed Code Generator

Help us improve by rating this tool.

4.7/5
1,116 reviews