HTML Iframes
HTML Iframes
Embedded content is common on websites. Part of what makes the web so powerful
is our ability to pull content from multiple servers to build a coherent website
experience
For example, embedded videos can add a lot of value to your pages. They help
engage, inform and delight your visitors, as long as they appear seamless with your
other content
If you want to embed YouTube videos - or any type of embeddable content- in your
own website’s HTML, one option is to utilize the iframe element.
What is an Iframe? How to embed content
with Iframe?
"An iframe, short for inline frame, is an HTML element that contains another
HTML document within it.
The iframe element is specified with the iframe tag. It may be placed anywhere in
an HTML document, and thus anywhere on a web page. Iframes are most often
used to embed specific content from one web page — like a video, form, document,
or even a full web page — within a different web page."
https://blog.hubspot.com/website/what-is-an-iframe
"This is a powerful capability in HTML — you can take any content from any
website (with permission) and place it on your own site to enhance your content."
https://blog.hubspot.com/website/what-is-an-iframe
How to make an Iframe?
This tag requires a src (source) attribute, which specifies the URL of the HTML file to be embedded on
the parent page
<iframe src="URL"></iframe>
This code will embed a web page onto its parent page
How are iframes used?
● Websites often use iframes to embed media from external websites. For example, here’s the
embed code for a HubSpot YouTube video embedded at the top of this post
</iframe>
● Embedded maps are another common use of iframes. Google Maps allows you to copy embed
code from any map location and display it on your website
● Also, display advertisements are often created with iframes. While images and gifs are static
elements, a fully embedded HTML document allows for scripting. With this method, ads can be
made interactive, as well as track impressions and clicks.
https://blog.hubspot.com/website/what-is-an-iframe
Using Iframes: Some Words of Caution
● First, make absolutely sure that the site or content you embed is trustworthy and secure. If attackers
successfully inject harmful code into a web page that you embed, it could harm your website too.
● Second, iframes can affect page performance if the embedded content takes too long to retrieve from its
host. Avoid placing too many iframes on a single page (unless you’re writing an informative blog post
about them), and consider taking advantage of the loading attribute
“lazy” sets the iframe to load only after it enters the visitor’s view, which works to decrease the time of
initial page load.
● Finally, consider the effect of iframes on your pages’ SEO. Google recommends avoiding iframes and
other rich media content on your website, as this content is harder to index than plain HTML content. If
you still want to use an iframe, provide text-based links to any content linked in your iframe if you can
so search engine crawlers can recognize them.
Iframe is one of the oldest HTML elements, and its resilience and usefulness tell us it’s
here to stay for a while. For embedding content, this element is a must for your HTML
tool belt.
THANK YOU