💡 Tip: Login now to track your course progress and unlock your downloadable certificates instantly!

HTML Iframes

An iframe (short for inline frame) is an HTML element that allows you to embed another webpage or document inside the current webpage. It acts like a window or a mini browser within your page.

Iframe Syntax

<iframe src="https://www.example.com" title="Iframe Example"></iframe>

Iframe Attributes:

  • src – The URL of the page to embed.
  • title – Provides a text description (important for accessibility).

Iframe Attributes Explained

AttributeDescriptionExample
srcSpecifies the URL of the page to embed.<iframe src="https://example.com"></iframe>
heightSets the height of the iframe.<iframe src="page.html" height="400"></iframe>
widthSets the width of the iframe.<iframe src="page.html" width="600"></iframe>
titleProvides a title for accessibility.<iframe src="page.html" title="Demo"></iframe>
nameUsed to name the iframe (useful for targeting links).<iframe name="myFrame"></iframe>
sandboxAdds security restrictions (disables scripts, forms, etc.).<iframe src="page.html" sandbox></iframe>
allowfullscreenAllows the iframe to display full-screen content.<iframe src="video.html" allowfullscreen></iframe>
loadingControls loading behavior (lazy or eager).<iframe src="page.html" loading="lazy"></iframe>
referrerpolicyControls the referrer information sent when loading content.<iframe src="page.html" referrerpolicy="no-referrer"></iframe>

Example: Embedding a Website

<iframe src="https://www.html5andcss3.org" width="800" height="400" title="HTML5 & CSS3"></iframe>

Example: Embedding a YouTube Video

<iframe width="560" height="315"
src="https://www.youtube.com/embed/dQw4w9WgXcQ"
title="YouTube video player"
frameborder="0"
allowfullscreen>
</iframe>

Example: Using the sandbox Attribute

<iframe src="/form.html" width="600px" height= "450px" sandbox></iframe>

<!--Default sandbox value is restricted to submit any form or script. To submit the form you need to allow it with sandbox. Try using sandbox="allow-forms" and it will let you submit the form. -->

This prevents the embedded page from running scripts or submitting forms — improving security.

Targeting Links to an Iframe

You can load content dynamically into an iframe using the name attribute.

<iframe name="myFrame" width="600" height="300"></iframe>

<a href="https://www.wikipedia.org" target="myFrame">Open Wikipedia in Iframe</a>

When you click the link, it loads inside the iframe instead of opening a new page.

Iframe Best Practices

  • Use the title attribute for accessibility.
  • Add sandbox to improve security.
  • Use loading="lazy" to improve performance.
  • Avoid overusing iframes — they can slow down the page and complicate SEO.

Sign In Form

User your email and password to singn in

Don’t have an account, signup here : 

HTML5 & CSS3

Tools and Tutorials

Want a Website

Want a website for your business ?

Please fill out the details below, so we can reach out to you.

Registration Form

Signup to track your record and much more.

We have sent you an email with a registration link. Please click the link to verify your email address, or enter the 6-digit OTP provided in the email.

Didn't receive the OTP. Regenerate OTP Resend