An HTML iframe
(short for inline frame) is used to embed another HTML document within the current document. This is often used to display content from a different website or web page within the context of the current page.
The iframe
element has a number of attributes that can be used to customize its behavior and appearance. Here are a few examples:
src
: Specifies the URL of the document to be embedded.width
andheight
: Specifies the dimensions of the iframe.frameborder
: Specifies whether or not to display a border around the iframe.scrolling
: Specifies whether or not to display scrollbars within the iframe.
Here is an example of how to use an iframe to embed a Google Map within an HTML document:
<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d2796.4072597942483!2d-122.08232418422117!3d37.42222697984941!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x808580a624b828ab%3A0x29b5c91b85f5f5c6!2sGolden%20Gate%20Bridge!5e0!3m2!1sen!2sus!4v1635967102456!5m2!1sen!2sus" width="600" height="450" style="border:0;" allowfullscreen="" loading="lazy"></iframe>
This will embed a Google Map with the specified dimensions and display options.
While iframes can be useful for displaying content from other sources, they can also be used to display malicious content or be used for phishing attacks. Therefore, it is important to use iframes judiciously and only embed content from trusted sources.