HTML iframe Tag

HTML <iframe>Tag: The HTML<iframe> tag defines an inline frame. And the HTML ” iframe ” tag defines a rectangular region within the document in which the browser can display a separate document, including scrollbars and borders. An inline frame is used to embed another document within the current HTML document.

 HTML <iframe>Tag

This HTML iframe tag supports both the global and the event attributes. The ‘ src ‘ attribute is used to specify the URL of the document that occupies the inline frame.

Syntax: <iframe src=”URL”> </iframe>



Setting Height and Width in the HTML iframe

The height and width attributes are used to specify the size of the iframe. While the attribute values are specified in pixels by default, but they can also be specified in percentage like ” 80% “.

Browser compatibility

The HTML<iframe> tag is supported by different types of attributes.

  • Chrome
  • Firefox
  • Opera
  • Safari
  • Internet Explorer

Example:

<!DOCTYPE html>
<html>
<body>
<iframe src="https://tutorials.freshersnow.com/">
</iframe>
</body>
</html>

Output:

html iframe tag

Removing the Border in iframe

By default, iframe has a border around it. To remove the border, we must use the style attribute and use the CSS border property.

Example:

<!DOCTYPE html> 
<html> 
<body> 
<p>Content goes here</p> 
<iframe src="https://en.wikipedia.org/wiki/Main_Page"
   height="400" width="400" style="border:none;"></iframe> 
<p>Content goes here</p> 
</body> 
</html>

Output:

html iframe tag noborder

Attributes that are supported by the <iframe> tag

Attribute Value Description
align left
center
right
middle
bottom
Specifies the alignment of an iframe according to surrounding elements
frameborder 1
0
Specifies whether or not to display a border around an iframe
height pixels Specifies the height of an iframe
longdesc URL Specifies a page that contains a long description of the content of an iframe
marginheight pixels Specifies the top and bottom margins of the content of an iframe
marginwidth pixels Specifies the left and right margins of the content of an iframe
name text Specifies the name of an iframe
scrolling yes
no
auto
Specifies whether or not to display scrollbars in an iframe
src URL Specifies the address of the document to embed in the iframe
width pixels Specifies the width of an iframe