<iframe> tag

HTML <iframe> tag

Iframe is known as inline frame. It allows us to present a web page within same web page.

Syntax:
<iframe src=”URL”></iframe>

Example

<iframe src="https://www.tutorialbrain.com/">
  <p>Your browser does not support iframes.</p>
</iframe>

How Browser will display

BLOCK Level.

Difference between HTML4.01, XHTML and HTML5

HTML4 XHTML HTML5
NA NA New attribute were added for <iframe> tag but few attributes were also deprecated.

Attributes used with <iframe> tag

Attribute Description
height Sets the height of the <iframe> in pixels.
name Set the name of the <iframe> using a text.
sandbox Adds other restrictions to the content of the <iframe>. This can take any of these values -

  • allow-scripts

  • allow-forms

  • allow-popups

  • allow-pointer-lock

  • allow-same-origin

  • allow-top-navigation
  • src Defines the URL of the source document of the <iframe>.
    srcdoc This defines the HTML content of the page to show in the <Iframe> using an HTML_Code.
    width Sets the width of the <iframe> in pixels.
    align To align the iframe with respect to its nearby elements. The alignment can be - top, right, bottom, left or middle.
    (HTML5 does not support this attribute when it is used with the <iframe> tag).
    frameborder This is a boolean attribute which can either take a value of 0 or 1. This decides whether to show a border around the iframe or not.
    (HTML5 does not support this attribute when it is used with the <iframe> tag).
    longdesc Defines a URL to show a page containing a long description about the content of the <iframe>.
    (HTML5 does not support this attribute when it is used with the <iframe> tag).
    marginheight Shows top and bottom margin for the content of the <iframe> using pixels.
    (HTML5 does not support this attribute when it is used with the <iframe> tag).
    marginwidth Shows left and right margin for the content of the <iframe> using pixels.
    (HTML5 does not support this attribute when it is used with the <iframe> tag).
    scrolling To decide if the scrollbar will appear for <iframe> or not. It can take following values -

  • scrolling="yes" - To show the scrollbar always

  • scrolling="no" - Never show the scrollbar

  • scrolling="auto" - This is the default. This informs the browser to add scrollbars only when it is needed

  • (HTML5 does not support this attribute when it is used with the <iframe> tag).

    Global Attributes

    The <iframe> tag supports Global attributes.

    Event Attributes

    The <iframe> tag supports Event attributes.

    Default CSS Value

    display: block;

    Supporting Browsers

    supporting-browsers for tags

    Related Tags

    None

    Tutorials for all brains!