Tutorialspoint.dev

HTML | Iframes

Significance of Iframe in HTML :

Iframe 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 inline frame.

Syntax :



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="400" width="400"></iframe>
  
<p>Content goes here</p>
  
</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.



<!DOCTYPE html>
<html>
<body>
  
<p>Content goes here</p>
  
   height="400" width="400" style="border:none;"></iframe>
  
<p>Content goes here</p>
  
</body>
</html>

OUTPUT :

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

<!DOCTYPE html>
<html>
<body>
  
<p>Content goes here</p>
  
  height="400" width="400" style="border:4px solid black;"></iframe>
  
<p>Content goes here</p>
  
</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.

<!DOCTYPE html>
<html>
<body>
  
<iframe height="300px" width="100%"
  src="demo_iframe.htm" name="iframe_a"></iframe>
  
  target="iframe_a">Wikipedia</a></p>
  
</body>
</html>

OUTPUT :





This article is attributed to GeeksforGeeks.org

leave a comment

code

0 Comments

load comments

Subscribe to Our Newsletter