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>

Exception Occured:

TypeErrorException
Messageerror_log(app.log): Failed to open stream: Permission denied
File/home/dh_czz6eb/tutorialwalk.com/common/error.php
Line36
Trace#0 (): log_error(2, 'error_log(app.log): Failed to open stream: Permission denied', '/home/dh_czz6eb/tutorialwalk.com/common/error.php', 36)
#1 /home/dh_czz6eb/tutorialwalk.com/common/error.php(36): error_log('27-05-2024 01:56:27 am (IST),/home/dh_czz6eb/tutorialwalk.com/common/common.php,193,0,ErrorException,Optional parameter $per_page declared before required parameter $href is implicitly treated as a required parameter,/html/html-iframes.html,#0 /home/dh_czz6eb/tutorialwalk.com/common/error.php(115): log_error(8192, 'Optional parame...', '/home/dh_czz6eb...', 193)
#1 [internal function]: check_for_fatal()
#2 {main}
', 3, 'app.log')
#2 /home/dh_czz6eb/tutorialwalk.com/common/error.php(8): log_exception(ErrorException)
#3 /home/dh_czz6eb/tutorialwalk.com/common/error.php(115): log_error(8192, 'Optional parameter $per_page declared before required parameter $href is implicitly treated as a required parameter', '/home/dh_czz6eb/tutorialwalk.com/common/common.php', 193)
#4 (): check_for_fatal()
REQUEST_URI/html/html-iframes.html