HTML <iframe>
Published Jul 1, 2022
Contribute to Docs
The <iframe> element represents a container used to embed a second web page inside the current one. It can be used for content from the same domain as the parent, or even from a second domain.
Syntax
<iframe></iframe>
<iframe> is an element that uses attributes to define important properties. It should not contain any elements between the opening and closing tags. Common attributes are:
src, which specifies the URL to embedheight, which specifies the height of the<iframe>and defaults to 150 pixelswidth, which specifies the width of the<iframe>and defaults to 300 pixels
Additional attributes set security policies (using csp or referrerpolicy attributes), or enable features for the iframe (using allow or sandbox attributes)
Example
<html><head> </head><body><h1>This text is from the current webpage</h1><!-- This will add https://www.codecademy.com/learn to the current page in an embedded frame --><iframeheight="300"width="300"src="https://www.codecademy.com/learn"></iframe></body></html>
This will render the following output:

Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn HTML on Codecademy
- Front-end engineers work closely with designers to make websites beautiful, functional, and fast.
- Includes 34 Courses
- With Professional Certification
- Beginner Friendly.115 hours
- Start at the beginning by learning HTML basics — an important foundation for building and editing web pages.
- Beginner Friendly.7 hours