New Year's Sale:

Up to 69 % OFF

03

:

11

:

54

:

57

Zyro encyclopedia

Learn about online business

Zyro Glossary Website builder

iFrame

What is iFrame?

iFrame stands for Inline Frame, and is an HTML element that allows you to embed another HTML document on your webpage. It is a popular method to provide useful information and media that is not available natively on your site. 

One of the main benefits of using iFrame in HTML is that you don’t have to upload the external content and host it on your site, which saves you a lot of time and storage space. 

This embedded content can integrate into your website. However, it still offers its own set of configurations, which you can edit using CSS or Javascript. 

Here are some of the most popular sources that iFrame supports:

  • YouTube video player
  • Ad banners
  • Facebook and Instagram posts
  • Twitter tweets
  • Directions and Street View images on Google Maps

Embedding content from third-party websites will not infringe the copyright as you don’t steal any data nor claim that it is yours. You only share an HTML document, which still points to the source. 

Example of how to use iFrames

To use iFrame, you need to open the HTML document of your page and insert the <iframe> tag on a specified location using the following code:

<iframe src=”URL”></iframe>

Here’s a breakdown of the iFrame elements used in the code:

  • <iframe> … </iframe> – the opening and closing iFrame tag
  • src – short for source code file, is a target attribute that specifies the embedded document
  • “URL” – the page URL that you want to embed

If you want to embed a document from www.example.com,the code should look like this: 

<iframe src=”https://www.example.com/embeddedcontent”></iframe>

A document from example.com will be displayed, complete with its border and scroll bar. However, the frame size follows the default 300px width and 150px height. 

To change this, simply add width and height attributes to the code and enter the desired value. For example:

<iframe src=”https://www.example.com/embeddedcontent” width=”680″ height=”480″></iframe>

There are also other iFrame attributes that you can add as well, such as:

  • allowfullscreen – allows the readers to open <iframe> in a full-screen mode 
  • frameborder – removes or draws a border around the frame
  • scrolling – enables or disables the scroll bar

Keep in mind that an HTTP website can embed an iFrame of an HTTPS URL, but not the other way around.

iFrame impact on website performance and security

While iFrame is widely used, there are several key points you need to consider before using it. 

Since you have no control over the external content, using it can pose a serious security risk on your websites. If you don’t carefully pick which website to embed, you might end up being the victim of cross-site attacks. 

Some of the worst scenarios involve phishing and hacking, which can harm your system, website visitors, and brand reputation. Therefore, we recommend you to embed iFrame content only from trusted sources. 

Another disadvantage is that it can negatively impact your website appearance. 

As the web pages and the embedded content are designed differently, it is harder to provide a balanced viewing experience for the readers. What’s more, if the content owner changes the URL, you are left with an empty space on your page. 

SEO is also one of the aspects that can be affected by an Inline Frame. Google isn’t be able to crawl the content unless the text-based information is provided. 

Additionally, using HTML iFrames excessively slows your website down as more resources are required to load them. As a result, it might lower your SERP ranking and damage user experience. 

Written by

Author avatar

Olivia

Olivia is a writer for Zyro and an eCommerce know-it-all. Having spent many years as a retail buyer, she loves writing about trend forecasting, brand building, and teaching others how to optimize online stores for success. She lives in London and spends a lot of time exploring the city’s parks with her whippet.

Got a business idea? Build it with Zyro.

Get started