Format Code Now
/
Web & markupHTML iFrame Generator Next: HTML Link Generator ›

HTML iFrame Generator

WM-33

Type the address and a title, choose lazy loading, a referrer policy and a sandbox, and copy an iframe element. The title is required, since it is how screen reader users learn what the frame holds.

Runs in your browser. Nothing is uploaded.

Key: value lines (src: and title: are required; also width:, height:, name:, allow:, allowfullscreen:)

HTML

How to use it

  1. Write src: with the page to embed and title: describing it.
  2. Add width: and height: in pixels if you want a fixed size.
  3. Choose loading, referrerpolicy and sandbox.
  4. Copy the iframe.

The sandbox attribute

An empty sandbox attribute applies every restriction: no scripts, no forms, no popups, and the frame is treated as a different origin from your page. Each token you add, such as allow-scripts or allow-forms, lifts one restriction. Be careful with allow-scripts together with allow-same-origin: if the embedded page comes from your own origin, it can remove its own sandbox, so use that pair only for content you trust. Many third-party embeds need scripts to work, so a strict sandbox will break them.

Loading, referrer and who can be embedded

loading="lazy" tells the browser to delay loading an off-screen frame until the visitor scrolls near it. referrerpolicy controls how much of your address is sent to the framed site, and most browsers default to strict-origin-when-cross-origin. Whether a site can be embedded at all is decided by that site through X-Frame-Options or the frame-ancestors directive, so a blank frame often means the site refused. This tool cannot check that.

Error messages and what to do

MessageWhat it meansFix
Add a "src:" line with the address of the page to embed.There was no src: line.Add src: followed by the address.
Add a "title:" line. An iframe needs a title so screen reader users know what it holds.There was no title: line.Add title: with a short description of the frame.
Links that start with javascript: or vbscript: are not generated. Use a normal URL.The address used a script scheme.Use an http or https address.

Questions people ask

How do I embed a website in HTML?

Use an iframe with src set to the address, a title that describes it, and a width and height. The site you embed must allow it; some refuse with a header, and the frame then stays blank.

Why does an iframe need a title?

Screen readers announce the title when the user reaches the frame. Without it, the user hears only that there is a frame, and has to enter it to find out what it holds. This tool requires the title for that reason.

What does sandbox do on an iframe?

It restricts what the framed page can do. With no tokens, it blocks scripts, forms, popups and same-origin access. Tokens such as allow-scripts and allow-forms switch individual abilities back on.

How do I make an iframe load lazily?

Add loading="lazy". The browser then waits to fetch the frame until it is close to the visible area, which saves bandwidth for frames far down the page. Choose it from the loading select.

Can I use a percentage width on an iframe?

Not in the width attribute, which takes a whole number of pixels. Use CSS for percentages, such as width: 100%. The tool rejects values such as 50% in the width: and height: lines for this reason.

About this tool

Writes one iframe. The title is required here because it is the iframe accessible name. Width and height are written as plain pixel numbers, which is what the HTML attributes allow; use CSS for percentages. The sandbox select adds the listed tokens only: with allow-scripts and allow-same-origin together, a page from the same origin as yours can remove its own sandbox, so use that pair only for content you trust. A strict sandbox blocks scripts, forms, popups and more, so many embeds will not work inside it. Whether a site allows being embedded is decided by that site (X-Frame-Options or frame-ancestors), and this tool cannot check it. javascript: addresses are refused. Optional lines: id:, class:, title:, lang:, data-* and aria-*.

Format Code Now: free, no ads, no accounts. Your input stays in your browser.