iframe {
  border: 1px solid black;
  width: 100%; /* takes precedence over the width set with the HTML width attribute */
}

Attributes

This element includes the global attributes.

allow

Specifies a Permissions Policy for the

Without this title, they have to navigate into the

Result

Embedding source code in an

Here's how to write escape sequences when using srcdoc:

  • First, write the HTML out, escaping anything you would escape in a normal HTML document (such as <, >, &, etc.).
  • < and < represent the exact same character in the srcdoc attribute. Therefore, to make it an actual escape sequence in the HTML document, replace any ampersands (&) with &. For example, < becomes &lt;, and & becomes &amp;.
  • Replace any double quotes (") with " to prevent the srcdoc attribute from being prematurely terminated (if you use ' instead, then you should replace ' with ' instead). This step happens after the previous one, so " generated in this step doesn't become &quot;.

Result

Technical summary

Content categories Flow content, phrasing content, embedded content, interactive content, palpable content.
Permitted content None.
Tag omission None, both the starting and ending tags are mandatory.
Permitted parents Any element that accepts embedded content.
Implicit ARIA role No corresponding role
Permitted ARIA roles application, document, img, none, presentation
DOM interface HTMLIFrameElement

Specifications

Specification
HTML
# the-iframe-element

Browser compatibility

See also