HTML <iframe> Tag

Last Updated : 23 Jul, 2025

HTML <iframe> Tag facilitates embedding the content from another source such as a video, map, or external website within a webpage. It simply specifies an inline frame.

Syntax

<iframe src=
"https://www.geeksforgeeks.org/"
title="GeeksforGeeks">
</iframe>

Note: It is important to include a title attribute for the <iframe> tag. Screen readers use this attribute to announce the purpose or content of the link.

Attributes

The below table shows the attribute, value, and description of the HTML <iframe> tag.

Attributes

Values

Descriptions

widthpixelsAdjusts the width of the <iframe>. The default is 300 pixels.
srcURLSpecifies the address of the document to embed.
allowfullscreentrue or falseAllows the <iframe> to activate fullscreen mode.
allowpaymentrequesttrue or falseEnables the Payment Request API for cross-origin iframes.
loadingeager or lazyDetermines when the browser should load the <iframe>.
srcdocHTML codeSets the HTML content to display within the <iframe>.
sandboxallow-forms, allow-pointer-lock, allow-popups, allow-same-origin, allow-scripts, allow-top-navigationEnforces restrictions for content within the <iframe>.
allowFeature policy stringSpecifies a feature policy for the <iframe>.
heightpixelsSets the height of the <iframe>. Default is 150 pixels.
nameTextSpecifies a name for the <iframe>.
referrerpolicyno-referrer, no-referrer-when-downgrade, origin, origin-when-cross-origin, same-origin, strict-origin-when-cross-origin, unsafe-urlControls referrer information for fetching the iframe.

The <iframe> tag supports the Global Attributes and Event Attributes in HTML.

Example 1: Implementation of the iframe tag by using allowfullscreen attribute for activating fullscreen mode.

HTML
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" 
          content="width=device-width, 
                   initial-scale=1.0">
    <title>HTML Iframe Tag</title>
</head>

<body style="text-align: center;">
    <h1 style="color: green;">
          GeeksforGeeks
      </h1>

    <iframe width="400" 
            height="200" 
            src=
"https://media.geeksforgeeks.org/wp-content/uploads/20240108102825/mern.mp4"
            allowfullscreen loading="lazy">
    </iframe>
</body>

</html>

Output:

file
iFrane Example ScreenShot


frt

Example 2: Another example illustrating the implementation of iframe tag by using allowfullscreen attribute for activating fullscreen mode and iframe border.

HTML
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" 
          content="width=device-width, 
                   initial-scale=1.0">
    <title>HTML Iframe Tag</title>
</head>

<body style="text-align: center;">
    <h1 style="color: green;">
          GeeksforGeeks
      </h1>

    <iframe width="400"
            height="200"
            src=
"https://media.geeksforgeeks.org/wp-content/uploads/20240108102825/mern.mp4"
            allowfullscreen style="border: 5px solid green;
                                   box-sizing: border-box;">
    </iframe>
</body>

</html>

Output:

der

Supported Browsers

  • Chrome 1
  • Edge 12
  • Safari 4
  • Firefox 1
  • Opera 15
Comment