Free tool · runs in your browser

Responsive iframe Wrapper

Paste any existing iframe — YouTube, Vimeo, Wistia, Loom, Maps, anything — pick a target aspect ratio, and get back a modern aspect-ratio responsive wrapper as a self-contained inline snippet or a clean class-based HTML + CSS pair.

Output style

One self-contained snippet — paste anywhere, no stylesheet needed.

Responsive HTML

<div style="aspect-ratio:16 / 9;width:100%">
  <iframe style="width:100%;height:100%;border:0" loading="lazy" title="Embedded content" src="https://www.youtube-nocookie.com/embed/dQw4w9WgXcQ" allowfullscreen></iframe>
</div>

Uses the modern aspect-ratio CSS property (Chrome 88+, Firefox 89+, Safari 15+). Fixed width / height / style attributes are stripped from your iframe; title and loading="lazy" are added if missing.

How to use this tool

  1. 01

    Paste your iframe code

    Any HTML iframe snippet.

  2. 02

    Set the aspect ratio

    Match your source video's aspect ratio.

  3. 03

    Pick output style

    Inline (one snippet) or separate CSS (cleaner for production).

Why this matters

A fixed-size iframe is one of the most common mobile layout bugs on the web: the embed keeps its hard-coded pixel width, blows past the content column on a phone, and either forces a horizontal scrollbar or gets clipped — and because the iframe has no intrinsic aspect ratio, naively setting width:100% just letterboxes it at a wrong fixed height. Every video host hands you embed code with baked-in width and height attributes, so this problem shows up the first time anyone views the page on something smaller than a laptop.

This tool strips the fixed sizing, wraps the iframe in a container that owns the aspect ratio via the modern aspect-ratio CSS property, and gives you the choice between a portable inline snippet and a maintainable class-based HTML + CSS pair. It also injects an accessible title and loading="lazy" if your pasted iframe is missing them. If you don't have an iframe yet, the Embed Code Generator builds a responsive one from a video URL directly.

Related tools

FAQ

An iframe is a replaced element with intrinsic width and height attributes baked into the markup, so it behaves like a fixed box rather than a fluid one — set `width=560 height=315` and it stays 560×315 no matter how narrow the viewport gets, causing horizontal scroll on phones. Unlike an `<img>`, an iframe has no intrinsic aspect ratio the browser can use to scale height from width. The fix is to wrap it in a container that owns the aspect ratio and stretch the iframe to fill that container — which is exactly what this tool generates.

Explore the full toolkit

94 free tools covering titles, tags, thumbnails, scripts, captions, embeds, schema, and in-browser video processing.

Browse all tools →