iFrame in HTML
An <iframe> (Inline Frame) is used to embed another webpage, video, or content inside the current HTML document. Unlike <frameset>, which is deprecated, <iframe> is still widely used in modern web development.
Basic Example of <iframe>
<iframe src="https://www.example.com" width="600" height="400"></iframe>
Common Attributes of <iframe>
Attribute | Description | Example |
---|---|---|
src | URL of the embedded page | <iframe src="page.html"> |
width | Width of the iframe (in px or %) | <iframe width="800"> |
height | Height of the iframe | <iframe height="500"> |
frameborder | Adds/removes border (0 = No , 1 = Yes ) | <iframe frameborder="0"> |
allowfullscreen | Enables fullscreen mode | <iframe allowfullscreen> |
name | Assigns a name to the iframe | <iframe name="myFrame"> |
Embedding YouTube Videos
<iframe width="560" height="315"
src="https://www.youtube.com/embed/dQw4w9WgXcQ"
frameborder="0"
allowfullscreen>
</iframe>