HTML iframe Tag

The HTML <iframe> tag specifies an inline frame. An inline frame is used to embed another document within the current HTML document.

Syntax

<iframe src="URL" title="description"></iframe>

Example

<!doctype html>
<html>
   <head>
      <title>HTML iframe tag</title>
   </head>
   <body>
      <h1>Iframe Example</h1>
      <iframe src="https://krtricks.in/learn-programming/" title="Learn Coding Free." width="400px" height="300px">
      </iframe>
   </body>
</html>

Output:

Iframe tag html

Attributes

Attribute Value Description
allowfullscreen true
false
Specifies whether the frame can be open in a full-screen mode or not.
allowpaymentrequest true
false
Specifies whether the frame can be allowed to make payment.
frameborder 0
1
Specifies whether the frame border is displayed or not.
height pixels Specifies the height of the frame. The default height of the iframe is 150px;
longdesc URL Specifies the page which has a long description content.
name text Specifies the iframe name.
sandbox allow-forms
allow-pointer-lock
allow-popups
allow-same-origin
allow-scripts
allow-top-navigation
It is used to apply extra restrictions for the iframe content.
scrolling yes
no
auto
Specifies the scrollbar.
src URL Specifies the URL of the content to be loaded into the frame.
srcdoc HTML_code Specifies the page to show the content in the frame.
width pixels Specifies the width of the frame. The default width of the iframe is 300px;

Global Attributes

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

Event Attributes

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

Supported Browsers

Element Chrome Firefox IE Opera Safari
<iframe> Yes Yes Yes Yes Yes

Leave a Comment

Your email address will not be published.