w3resource

HTML5: How to specify the address of the document to embed in the iframe element?

Go to Exercise page

Solution:

HTML Code:

<!DOCTYPE html><!-- Declaration specifying the document type -->
<html><!-- Opening tag for the root element of the HTML document -->
<head><!-- Opening tag for the document's header section -->
<meta charset="utf-8"><!-- Metadata tag specifying the character encoding of the document -->
<title>How to specify the address of the document to embed in the iframe element</title><!-- Title of the HTML document -->
</head><!-- Closing tag for the document's header section -->
<body><!-- Opening tag for the document's body section -->
<iframe src="https://www.w3resource.com/html-css-exercise/basic/solution/iframe-answer.html"><!-- Inline frame element specifying the URL of the document to embed -->
</iframe><!-- Closing tag for the iframe element -->
</body><!-- Closing tag for the document's body section -->
</html><!-- Closing tag for the root element of the HTML document -->

Explanation:

  • This HTML code demonstrates how to specify the address (URL) of the document to embed within an iframe element.
  • The <iframe> element is used to embed content from another HTML document or website. In this case, its src attribute specifies the URL of the document to be embedded.
  • The URL provided in the src attribute points to the document "https://www.w3resource.com/html-css-exercise/basic/solution/iframe-answer.html".
  • When the HTML document is rendered, the content of the specified document will be displayed within the iframe element.

Live Demo :

See the Pen iframe-src-answer by w3resource (@w3resource) on CodePen.


See the solution in the browser

Supported browser

Firefox logo Chrome logo Opera logo Safari logo Internet Explorer logo
YesYesYesYesYes

Go to Exercise page

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/html-css-exercise/basic/iframe-src-answer.php