While iFrames can be necessary for embedding external content easily, they can also pose challenges for search engine optimization.

 

The HTML code used for iFrames adversely affects the page experience on the parent page. When an iFrame loads content from an external source, it can create loading delays, leading to poor user experience.

 

And as you know, search engines prioritize accessible designs and easy-to-use interfaces. Poor iFrame implementation can lead to restrictions that may even result in a Google penalty.

 

Let’s learn about iFrame SEO and how the iFrame tag interacts with JavaScript and other elements to influence search engine rankings.

 

What is an iFrame?

 

An iFrame, or inline frame, is an HTML element that allows developers or marketers to embed an external document within a current HTML document.

 

When an iFrame is loaded, it contains JavaScript code for dynamic content delivery, such as external ads or interactive features.

 

iFrames can load various types of content directly onto a webpage. These contents can be:

 

  • YouTube videos
  • Maps
  • Social media feeds
  • Web apps

 

Attributes like height and width can help web designers control the display size of the iFrame to enhance the visual layout of a site.

 

Also, a CSS border can be applied to customize the iFrame's appearance, merging with the surrounding text.

 

Examples of iFrames

Embedding a YouTube Video

An inline frame can effectively embed a video, enhancing user engagement. Developers can easily insert multimedia content using the <iframe> tag.

 

The attribute height and width control the display size, while the full-screen feature enables users to view the video in full-screen mode.

 

Adding a YouTube video using iFrames is really simple. Just copy the embed code from YouTube:

YouTube video embed code

 

And then paste the code where you'd like to embed the video on your website.

Embedding a Google Map

An inline frame can embed interactive elements like Google Maps, allowing users to explore locations directly on your website. Here’s how to embed a Google Map:

Embed code for adding Google Maps to website

 

The above example uses three different properties:

 

  • allowfullscreen: Enables full-screen mode for certain map sections.
  • frameborder="0" and style="border:0": Removes the default iframe border around the map.
  • referrerpolicy="no-referrer-when-downgrade": Sends the full URL in the Referer header, allowing proper API key restrictions.

 

Here's a look at a digital agency using Google Maps on their website with iFrames:

Online Optimism website with Google Maps embedded

Embedding a PDF Document

An iFrame can display PDF documents directly within a webpage. Hence, there is no need for users to download the file. Here’s a screenshot on the code on embedding a PDF:

How to embed a PDF document with iframes

 

In the above example, the src attribute defines the location of the PDF file, either on the web (using the URL) or on a local server (using the file path).

Embedding Social Media Posts (Like Twitter)

You can also embed social media content like a Tweet on a web page using iFrames. It increases engagement by displaying dynamic, interactive content directly on your website.

 

You can insert live social media updates using an iFrame with Twitter’s widget.

 

The <blockquote> tag includes the Tweet, while a JavaScript file is required to render it properly. Here is an example of what an embedded Twitter post looks like on a website:

Embedding a Twitter post using iFrames

 

Does iFrame Content Get Indexed?

 

Yes, iFrame content can be crawled and indexed.

 

Google search spiders can crawl iFrame content through DOM Flattening, where the browser combines all webpage elements, including iFrames, into a single structure.

 

However, Google does not treat all iFrame content equally.

 

When loading iFrames, Google requests additional HTTP to fetch the iFrame's content. While it can crawl and potentially index this content, it depends on how the iFrame is implemented. 

 

Using the index embedded directive is crucial for publishers who want to ensure specific iFrame content is indexed to boost their iFrame SEO strategy.

 

The index embedded directive is a meta tag or HTTP header that allows Google to index content embedded within an iFrame, even if the page containing the iFrame itself is marked with a noindex tag.

 

This is useful for publishers who want embedded content (like videos or widgets) to be indexed by Google when they are part of other sites.

 

Here is an example of using the meta tag in the <head> section:

 

<head><meta name="robots" content="noindex, indexifembedded"></head>

 

In this example, the page itself will not be indexed (noindex), but if this content is embedded in another site’s iFrame, it can be indexed (indexifembedded).

 

How do iFrames Impact SEO?

 

iFrames can have a significant impact on SEO, both positively and negatively. Here is how inline frames impact SEO:

SEO Credit

Unlike direct content placed within the HTML of your webpage, embedded content through iFrames is treated differently by search engines.

 

When web crawlers view a webpage, they look for original content that they can associate with that page.

 

Content directly included in the HTML is recognized as part of your site, contributing to its relevance and authority. Whereas, content displayed through an iFrame originates from a different source, which means that search engines may not associate it with your domain.

 

Therefore, using iFrames when necessary is advisable to ensure that the primary content remains visible and accessible to web crawlers.

Web Crawlers and Indexing

Search engines send web crawlers to analyze and index your site’s content.

SEO spider crawling a website

 

Crawlers can face difficulty in indexing iFrames due to several factors:

 

  • Content Accessibility: If the content within the iFrame is on a different domain (cross-origin), some crawlers might not access it due to security restrictions.
  • Noindex Tags: If the embedded content includes a noindex meta tag or an X-Robots-Tag header that prevents indexing, crawlers will not include it in their index.
  • JavaScript Rendering: Some iFrames rely on JavaScript to load content. If crawlers cannot render JavaScript, they may not see or index the iFrame's content.

 

To improve the indexing of iFrames and elevate your iFrame SEO, consider using the following:

 

  • Use a Valid Src Attribute: Use the iFrame tag properly with a valid src attribute pointing to accessible content.
  • Allow Cross-Origin Resource Sharing: If the iFrame content is from another domain, configure the server to allow CORS, enabling crawlers to access it.
  • Do Not Use Noindex Meta Tags: Ensure there are no noindex directives in the iFrame content that would block indexing. Structured Data: Implement structured data (like Schema.org) in the parent document to provide context to search engines about the iFrame content.
  • Use Canonical Tags: Use <link rel="canonical"> to point to the primary version of the content if applicable.

Pagespeed

Using iFrames can reduce PageSpeed because loading external content requires additional HTTP requests, which can slow down the page's overall load time.

 

The reason for reduced load time is because each iFrame pulls data from external sources, and if these sources are slow or have large files, it can negatively affect your website’s performance.

 

Moreover, iFrames can delay the rendering of other elements on the page, further impacting speed, especially on slower connections.

 

And as you know, a slow PageSpeed not only impacts Core Web Vitals scores, but leads to a poor user experience. In fact, several sources (including Google) have stated the impact of slow loading speed on bounce rate.

 

The findings are as follows: bounce rates increase by 32% as page load time goes from 1 second to 3 seconds.

Google research on page speed and bounce rates

 

And as SEOs, the last thing we want to do is negatively impact our page experience.

 

So the question really is, “Should I use iFrames to embed content if it could potentially reduce PageSpeed?

Duplicate Content Problems

In iFrames, the same content is embedded across multiple pages or sites. Hence, search engines have trouble deciding the original version.

 

It leads to a dilution of SEO credit and link equity.

 

To mitigate this issue, ensure the embedded content is unique to each page or properly canonicalized to avoid conflicts with other sites.

Ensure iFrame content is unique

 

Using SEO-friendly iFrames that clearly communicate the primary source can help search engines understand the relationship between the original content and its embedded instances.

 

What are the Benefits of iFrames?

 

Inline frames offer several benefits for web developers and content creators. It improves site performance when embedding external media and sharing content.

 

Here are the key advantages of using iFrames:

Faster Updating of Pages

iFrames allow for faster updating of pages that reference the iFrame, as content updates can be made to the embedded resource without changing the primary page.

 

This reduces the need to reload entire pages and increases efficiency.

Code Reusability

One major benefit of iFrames is code reusability.

 

Developers can reuse the same iFrame on multiple pages by embedding the same resource, which saves time and storage while reducing the number of lines of code needed to implement content across the site.

Embedding External Content and Media

iFrames simplify embedding content from third-party sources, such as videos, maps, and widgets.

 

By sharing external media files and utilizing iFrame tags, developers can integrate rich media without hosting it themselves, circumventing CORS restrictions and enabling cross-domain access.

Easy to Use and Maintain

iFrames are easy to use, requiring minimal setup to implement on a page.

 

They allow you to embed complex content without bloating your codebase. Inline frames enhance your website’s functionality, optimize content delivery, and maintain consistent branding, all while reducing the complexity of code.

 

Are iFrames Considered Cloaking?

 

No, iFrames are not inherently considered cloaking.

 

Cloaking is a black hat SEO practice where a website shows different content to search engines than it does to users, often to control search rankings.

What is cloaking

 

iFrames, when used appropriately, do not fall under this definition. However, technical aspects must be considered to ensure iFrames are used correctly without misleading search engines or users.

 

Wrapping Up

 

While HTML5 supports using iFrames and Google can index iFrame HTML code, it is best to avoid them wherever possible.

 

Some browsers and search engine crawlers may still not index the content within iFrames, ultimately leading to SEO issues.

 

You can use the <embed> tag as an alternative to iFrame. It is used for embedding multimedia content, such as PDFs, audio, and video, rather than full web pages.