Lesson 17 of 21 – HTML Iframe
81%

HTML Iframe

An inline frame (iframe) is an HTML element that loads another webpage inside the current webpage. It is commonly used for videos, maps, advertisements, and external web content.

Note: An iframe allows one webpage to be embedded inside another webpage.
What is an HTML Iframe?

An iframe is an HTML document embedded inside another HTML document.

<iframe src="URL"
title="description">
</iframe>
Basic Example
<iframe
src="https://www.example.com"
width="600"
height="400">
</iframe>

The src attribute specifies the webpage to display inside the iframe.

URL Types
URL Type Description
Absolute URL Points to another website.
Relative URL Points to a file within the same website.
Important Attributes
  • src – URL of embedded page
  • width – Width of iframe
  • height – Height of iframe
  • name – Name of iframe
  • loading – Controls loading behavior
  • sandbox – Adds security restrictions
  • allowfullscreen – Enables fullscreen mode
Security & Sandbox
<iframe
src="page.html"
sandbox>
</iframe>

The sandbox attribute provides extra security by restricting what the embedded page can do.

Key Points
  • Used to embed external webpages.
  • Commonly used for videos and maps.
  • Uses the src attribute.
  • Width and height control size.
  • Sandbox improves security.
  • Can be responsive using CSS.
  • Supports fullscreen mode.
  • SEO value is limited.

🧠 Quiz

Which attribute specifies the webpage displayed inside an iframe?