HTML Iframe

HTML iframe is used to browse the other HTML files or other browsing content in a specified frame. It is an inline element.

Iframe can contain the following browsing content.

  • web page/website

  • image

  • youtube video

Web Page

We have to write the address of website or web page which we want to embed.


<!DOCTYPE html>
 iframe can embed web pages
 <iframe src="files/value.html" ></iframe>
 iframe can embed website
 <iframe src="" ></iframe>

Try </>

src attribute specifies the address of browsing content. height and width attributes represent the vertical and horizontal dimensions of the Iframe.

allowfullscreen attribute allows full-screen size for the video.

You can add media using the iframe element but we recommend you to use video and audio elements.


Iframe can add an image in the page. But other attributes of an image can not be controlled.


iframe can embed image
<iframe src="files/logo.png"></iframe>

Try </>

Youtube video

we can add youtube video by writing the source code of video in the page.


<iframe src=";showinfo=0" frameborder="0" allowfullscreen></iframe>

Try </>

Firstly video is uploaded on youtube to add in a page. Then we get the source code from the embed option given below the video.

formborder defines the border for the iframe.

Iframe related attributes

name attribute

name attribute can make a link to be opened in named iframe. To understand it see the example below.


<a href="" target="link">Google</a>
<iframe name="link">
Try </>

In the above example, the link opens in the iframe. target attribute contains the name of the iframe.

Was this article helpful?