HTML Iframes


An HTML iframe is used to display a web page within a web page.


HTML Iframe Syntax

The <iframe> HTML tag defines an inline frame, which serves the purpose of embedding another document within the existing HTML document.

Tip: Remember to consistently add a title attribute to the <iframe>. This helps screen readers describe the content within the iframe accurately.


Iframe - Set Height and Width

Utilize the height and width attributes to define the dimensions of the iframe.

By default, dimensions (height and width) are specified in pixels.


You can also enhance the <iframe> by adding the style attribute and utilizing the CSS height and width properties:


Iframe - Remove the Border

By default, an iframe displays with a surrounding border.

For border removal, apply thestyle attribute and utilize the CSS border property:

CSS enables you to modify the iframe's border size, style, and color:


Iframe - Target for a Link

An <iframe> can serve as the target frame for a hyperlink. The link's targetattribute should point to the iframe's name attribute.


Chapter Summary

  • The <iframe> HTML tag defines an inline frame.
  • The src attribute specifies the URL of the page to be embedded.
  • Remember to always add a title attribute for screen readers.
  • The height and width attributes determine the dimensions of the iframe.
  • To eliminate the border around the iframe, apply the style border:none; to it.