...

Web Technologies - HTML

Back to Course

Lesson Description


Lession - #156 HTML Iframes



The HTML element <iframe> can be used to define an inline frame. The <iframe> tag is unrelated to the <frameset> tag; rather, it can occur anywhere in your page. The <iframe> element specifies a rectangular section within the content where the browser can show a distinct document, complete with scrollbars and borders. An inline frame is a type of frame that allows another page to be embedded into the current HTML text.
The src element specifies the URL of the document occupying the inline frame.
is the example to show how to use the <iframe> −


  <!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

Most <iframe> tag attributes, such as name, class, frameborder, id, longdesc, marginheight, marginwidth, name, scrolling, style, and title, function precisely like the equivalent <frame> tag elements.
The properties frameborder, marginwidth, longdesc, scrolling, and marginheight are deprecated in HTML5. These characteristics should not be used.

Sr.No Attribute & Description
1

src

This element specifies the name of the file that should be loaded in the frame. Any URL can be used as its value. For instance, src = "/html/top frame.html" loads an HTML file from the html directory.

2

name

This feature enables you to give a frame a name. It specifies the frame a document should be loaded into. This is especially crucial when you wish to make links in one frame that load pages in another, as the second frame requires a name to identify itself as the target of the connection.

3

frameborder

This attribute determines whether or not the frame's borders are visible; it overrides the value specified in the frameborder attribute on the tag if one is specified, and this can take one of two values: 1 (yes>
or 0 (no>
.

4

marginwidth

This feature specifies the width of the gap between the frame's left and right borders and the frame's content. The value is expressed in pixels. For instance, marginwidth = "10".

5

marginheight

This feature specifies the height of the gap between the frame's top and bottom borders and its contents. The value is expressed in pixels. For example, marginheight = "10".

6

height

The height of the <iframe> is specified by this property.

7

scrolling

This property governs the appearance of the scrollbars on the frame. This accepts the values "yes," "no," or "auto." For example, scrolling = "no" indicates that there should be no scroll bars.

8

longdesc

This feature allows you to offer a link to another website that has a detailed explanation of the frame's contents. For instance, longdesc = "framedescription.html"

9

width

The width of the < iframe> is specified by this property.