Blog
post page

How to Use iframes to Embed Websites Inside Your Web Page

Learn how to use iframes to embed external websites into your own webpage seamlessly. This guide covers customization, responsiveness, and solutions for common iframe issues.
Written By
author image
Mohsin Forhad
Senior Web Developer

How to Use iframes to Embed Websites Inside Your Web Page

How to Use iframes to Embed Websites Inside Your Web Page

Introduction

If you want to display another website inside your own webpage, an iframe is one of the easiest and most effective ways to do so. In this guide, we’ll walk you through how to use iframes, customize their appearance, and handle common issues.

What is an iframe?

An <iframe> (short for inline frame) is an HTML element that allows you to embed another webpage within your own page. It acts as a window that loads external content without redirecting the user.

Basic iframe Example

Here’s a simple example of how to embed a website using an iframe:

<iframe src="https://example.com" width="100%" height="600" style="border: none;"></iframe>

Explanation:

  • src="https://example.com" – Specifies the URL to embed.
  • width="100%" height="600" – Sets the dimensions of the iframe.
  • style="border: none;" – Removes the border for a cleaner look.

Customizing Your iframe

1. Making the iframe Scrollable

By default, if the embedded page is larger than the iframe, users should be able to scroll. However, if scrolling is disabled, you can force it using CSS:

iframe {
  width: 100%;
  height: 600px;
  border: none;
  overflow: auto;
}

2. Making a Responsive iframe

To ensure your iframe scales well on all screen sizes, wrap it in a responsive container:

<div style="position: relative; width: 100%; padding-top: 56.25%;">
  <iframe src="https://example.com"
          style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: none;"></iframe>
</div>

This maintains a 16:9 aspect ratio, making it ideal for videos or full-page

Common iframe Issues & Solutions

1. Website Blocks iframes (X-Frame-Options Error)

Some websites do not allow embedding due to security settings. If you see a message like “Refused to display in a frame”, the website has restricted iframe usage. Solutions include:

  • Checking if the site offers an iframe-compatible embed option (e.g., YouTube’s embed code).
  • Using a proxy or alternative embed methods.

2. iframe Not Filling the Container

If the iframe content appears cut off, ensure the parent container allows it to expand:

div {
  overflow: hidden;
}
iframe {
  width: 100%;
  height: 100%;
}

Conclusion

iframing is a powerful way to embed content without leaving your site. Whether you want to display a third-party tool, a blog post, or an external website, the iframe element provides a simple yet effective solution. However, keep in mind that some sites restrict iframe usage, so always check before implementing.

Need help implementing iframes on your Webflow or WordPress site? Let’s connect and build something amazing together! 🚀