Skip to content
Related Articles

Related Articles

HTML | Iframes
  • Difficulty Level : Medium
  • Last Updated : 18 Jul, 2019

Significance of Iframe in HTML :

The iframe in HTML stands for Inline Frame. The ” 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.

The ‘ src ‘ attribute is used to specify the URL of the document that occupies the iframe.

Syntax :

<iframe src="URL"></iframe>


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






<!DOCTYPE html>
<html>
  
<body>
  
    <p>Content goes here</p>
  
                                height="300" width="400">
    </iframe>
  
</body>
  
</html>


OUTPUT :

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>
  
            height="300" width="400" style="border:none;">
    </iframe>
  
</body>
  
</html>


OUTPUT :

Changing the size, style, and color of the Iframe’s border :
Example:




<!DOCTYPE html>
<html>
  
<body>
  
    <p>Content goes here</p>
  
     height="300" width="400" style="border:4px solid orange;">
  
    </iframe>
  
</body>
  
</html>


OUTPUT :

Target for a Link using Iframe :
An iframe can be used as the target frame for a link. The target attribute of the link must refer to the name attribute of the iframe.

Example:




<!DOCTYPE html>
<html>
  
<body>
  
    <p>Click the link text</p>
    <iframe height="300" width="350" src=
            name="iframe_a"></iframe>
  
    <p><a href=
"https://ide.geeksforgeeks.org/tryit.php" target="iframe_a">GeeksforGeeks IDE</a></p>
  
</body>
  
</html>


OUTPUT :
Before clicking the link text:

After Clicking link text:


Supported Browser: The <iframe> tag is supported by listed browsers:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Opera
  • Safari

full-stack-img

My Personal Notes arrow_drop_up
Recommended Articles
Page :