HTML5: How to specify the width of an iframe element?
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 width of an 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/em-answer.html" width="150%" hight="60"><!-- Inline frame element specifying the URL of the document to embed and its width -->
</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 width of an iframe element to display content from an external source within the HTML document.
- 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 external content.
- The width attribute sets the width of the iframe. In this example, it is set to "150%", which means the iframe's width will be 150% of the width of its container.
- However, there is a typo in the code where "hight" should be corrected to "height" for the height attribute.
- The height attribute is intended to specify the height of the iframe, but it is misspelled as "hight".
Live Demo:
See the Pen iframe-width-answer by w3resource (@w3resource) on CodePen.
See the solution in the browser
Supported browser
Yes | Yes | Yes | Yes | Yes |
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics