Enroll Course

100% Online Study
Web & Video Lectures
Earn Diploma Certificate
Access to Job Openings
Access to CV Builder



Online Certification Courses

HTML - Iframes

What is an iframe?

You can create an inline frame by making use of the HTML tag <iframe>. The <iframe> tag isn't somehow associated with <frameset> tag, instead, it can appear anywhere in your document. The <iframe> tag is responsible for defining an oblong section inside the document during which the browser can actually display a separate document, including the scrollbars and the borders. An inline frame is defined in other to place or embed another HTML document within the present HTML document.

The src attribute is employed to specify the URL of the document that occupies the inline frame.

Example

The following is an example of how to use an iframe tag in HTML: 

<!DOCTYPE html>
<html>

   <head>
      <title>HTML Iframes</title>
   </head>
	
   <body>
      <p>Document content goes here...</p>
      
      <iframe src = "/html/menu.htm" width = "555" height = "200">
         Sorry your browser does not support inline frames.
      </iframe>
      
      <p>Document content also go here...</p>
   </body>
	
</html>

The <Iframe> Tag Attributes

The attributes of the <iframe> tag include:

1. name,

2. class,

3. frameborder,

4. id,

5. longdesc,

6. marginheight,

7. marginwidth,

8. scrolling,

9. style, and

10. title

They all behave exactly like their similar attributes for the <frame> tag.

Note: The frameborder, marginwidth, longdesc, scrolling, marginheight attributes  are deprecated in HTML5. Do not make use these attributes.

Sr.No Attribute & Description
1

src

This attribute is used to give the file name that should be loaded in the frame. Its value can be any URL. For example, src = "/html/top_frame.htm" will load an HTML file available in html directory.

2

name

This attribute allows you to give a name to a frame. It is used to indicate which frame a document should be loaded into. This is especially important when you want to create links in one frame that load pages into an another frame, in which case the second frame needs a name to identify itself as the target of the link.

3

frameborder

This attribute specifies whether or not the borders of that frame are shown; it overrides the value given in the frameborder attribute on the <frameset> tag if one is given, and this can take values either 1 (yes) or 0 (no).

4

marginwidth

This attribute allows you to specify the width of the space between the left and right of the frame's borders and the frame's content. The value is given in pixels. For example marginwidth = "10".

5

marginheight

This attribute allows you to specify the height of the space between the top and bottom of the frame's borders and its contents. The value is given in pixels. For example marginheight = "10".

6

height

This attribute specifies the height of <iframe>.

7

scrolling

This attribute controls the appearance of the scrollbars that appear on the frame. This takes values either "yes", "no" or "auto". For example scrolling = "no" means it should not have scroll bars.

8

longdesc

This attribute allows you to provide a link to another page containing a long description of the contents of the frame. For example longdesc = "framedescription.htm"

9

width

This attribute specifies the width of <iframe>.

Corporate Training for Business Growth and School