HTML Java

HTML Iframe


HTML Iframes

  • An iframe is used to display a web page within a web page.
  • An HTML iframe is defined with the <iframe> tag.
  • Syntax:- <iframe src="URL"></iframe>

  • The src attribute specifies the URL (web address) of the inline frame page.


Iframe - Set Height and Width

  • Use the height and width attributes to specify the size of the iframe.
  • The height and width are specified in pixels by default.

Example

<html>
<body>
  <h2>HTML Iframes</h2>
  <iframe src="iframe.html" height="200" width="400"></iframe>
</body>
</html>
Try it »

Or CSS can be used to set the height and weidth of the iframe.


Iframe - Remove the Border

  • By default, an iframe has a border around it.
  • To remove the border, the style attribute is added and the CSS border property is used.

Example

<html>
<body>
  <h2>Remove the Iframe Border</h2>
  <iframe src="iframe.htm" style="border:none;"></iframe>
</body>
</html>
Try it »

With CSS, the size, style and color of the iframe's border can also be changed.


Example

<html>
<body>
  <h2>Custom Iframe Border</h2>
  <iframe src="iframe.htm" style="border:2px solid yellow;"></iframe>
</body>
</html>
Try it »


Iframe - Target for a Link

  • 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

<html>
<body>
  <h2>Iframe - Target for a Link</h2>
  <iframe height="300px" width="100%" src="iframe.html" name="iframe_a"></iframe>
</body>
</html>
Try it »