HTML Iframes

Bookmark
Learn about using iframes to embed HTML inside a HTML document.

<iframe> tag element represents a nested browsing context. It is displaying a web page within a web page. It is defined as follows,

<iframe src="URL" srcdoc="html" name="browse-name" ></iframe>

  • src attribute defines the URL page that should be nested in the iframe.
  • srcdoc content of the page that should be shown in iframe.
  • name is the name of the iframe nested browsing context.

iframe Example

<iframe src="/html/index.htm" width="200" height="200"></iframe>

iframe with srcdoc attribute

<iframe seamless sandbox="allow-same-origin"
              srcdoc="<p>Embedded HTML content in iframe.">
</iframe>

iframe as target for Link

iframe can be used a hyperlink anchor target as below.

<iframe src="htmltoc.html" name="iframe_hml"></iframe>
<p><a href="http://html/index.htm" target="iframe_hml">HTML Tutorial</a></p>