HTML Iframes

HTML Iframes

Sponsored Ads

An iframe stands for inline frame and is used to define a rectangular region in an html document which can be used to display another document within the document with scrollbars and borders. You can create an iframe using the <iframe> tag. An iframe can appear anywhere in the document and it as a bit different from the <frameset> tag.

Sponsored Ads

The src attribute is used to specify the url of the document that is displayed inside the iframe.

The width and height attribute are used to specify the width and height of the rectangular region.

Example

<body>
      <p>Document content goes here...</p> 
      <iframe src = "https://www.tutorialmanthra.com/html/html-background" width = "555" height = "200">
         Sorry your browser does not support inline frames.
      </iframe> 
      <p>Document content also go here...</p>
</body>

Output

Document content goes here…

Document content also go here…

The <Iframe> Tag Attributes

Most of the attributes of the <iframe> tag, including name, class, frameborder, id, longdesc, marginheight, marginwidth, name, scrolling, style, and title behave exactly like the corresponding attributes for the <frame> tag.

Sponsored Ads

Note − The frameborder, marginwidth, longdesc, scrolling, marginheight attributes are deprecated in HTML5. Do not use these attributes. Use CSS instead.

Sponsored Ads

src
The src attribute is used to specify the path name of the document that should be loaded in the iframe. Its value should be any url.
name
The name attribute is used to give a name to the iframe and can be used to indicate which frame a document should be loaded. The name tag is especially important when you to create a menu in one frame and the page is loaded in another frame. In such cases the second frame needs a name to identify as the target of the link.
frameborder
The frameborder attribte is used to specify whether the border of the frame is shown or not. Its value can be either 0 or 1.
marginwidth
The marginwidth attribute let you specify the width of the left and right margin. i.e. the space between the left and right content and frames border. The value is specified in pixels.
marginheight
The margin height attribute let you specify the top and bottom margin. i.e. the space between the content and the top and bottom border of the frame. The value is given in pixels.
height
The height attribute let you specify the height of the iframe.
width
The width attribute let you specify the width of the iframe.
scrolling
The scrolling attribute let you control the appearance of scrollbar on the iframe. Its value can be yes, no, or auto.
longdesc
The longdesc attribute let you provide a link to another page containing the long description of the contents of the iframe. Eg: longdescription.html

Sponsored Ads

%d bloggers like this: