HTML | <frame> Tag

HTML Frames are used to divide the web browser window into multiple section where each section can be loaded separately. A frameset tag is the collection of frames in the browser window.

Creating Frames: Instead of using body tag, use frameset tag in HTML to use frames in web browser. But this Tag is deprecated in HTML 5. The frameset tag is use to define how to divide the browser. Each frame is indicated by frame tag and it basically defines which HTML document shall open into the frame. To define the horizontal frames use row attribute of frame tag in HTML document and to define the vertical frames use col attribute of frame tag in HTML document.

Example:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
    <head>
        <title>Example of HTML Frames using row attribute</title>
    </head>
          
    <frameset rows = "20%, 60%, 20%">
        <frame name = "top" src = "C:/Users/dharam/Desktop/attr1.png" />
        <frame name = "main" src = "C:/Users/dharam/Desktop/gradient3.png" />
        <frame name = "bottom" src = "C:/Users/dharam/Desktop/col_last.png" />
        <noframes>
            <body>The browser you are working does not support frames.</body>
        </noframes>
    </frameset>
</html>                    

chevron_right


Output: The above example basically used to create three horizontal frames: top, middle and bottom using row attribute of frameset tag and the noframe tag is used for those browser who doesn’t support noframe.
frame tag

Example: This example illustrates the col attribute of frameset tag.



filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>    
    <head>
        <title>Example of HTML Frames Using col Attribute</title>
    </head>
          
    <frameset cols = "30%, 40%, 30%">
        <frame name = "top" src = "C:/Users/dharam/Desktop/attr1.png" />
        <frame name = "main" src = "C:/Users/dharam/Desktop/gradient3.png" />
        <frame name = "bottom" src = "C:/Users/dharam/Desktop/col_last.png" />        
        <noframes>
            <body>The browser you are working does not support frames.</body>
        </noframes>
    </frameset>
</html>                    

chevron_right


Output: The above example basically used to create three vertical frames: left, center and right using col attribute of frameset tag.
frame tag

Attributes of Frameset tag:

  • cols: The cols attribute is used to create vertical frames in web browser. This attribute is basically used to define the no of columns and its size inside the frameset tag.
    The size or width of column is set in the frameset in following ways:

    • Use absolute value in pixel
      Example:

      <frameset cols = "300, 400, 300">
    • Use percentage value
      Example:

      <frameset cols = "30%, 40%, 30%">
    • Use wild card values:
      Example:

      <frameset cols = "30%, *, 30%">

      In the above example * will take the remaining percentage for creating vertical frame.

  • rows: The rows attribute is used to create horizontal frames in web browser. This attribute is used to define no of rows and its size inside the frameset tag.
    The size of rows or height of each rows use following ways:

    • Use absolute value in pixel
      Example:

      <frameset rows = "300, 400, 300">
    • Use percentage value
      Example:

      <frameset rows = "30%, 40%, 30%">
    • Use wild card values
      Example:



      <frameset rows = "30%, *, 30%">

      In the above example * will take the remaining percentage for creating horizontal frame.

  • border: This attribute of frameset tag defines the width of border of each frames in pixels. Zero value is used for no border.
    Example:

    <frameset border="4" frameset>
  • frameborder: This attribute of frameset tag is used to specify whether three dimensional border should be displayed between the frames or not for this use two values 0 and 1, where 0 defines for no border and value 1 signifies for yes there will be border.
  • framespacing: This attribute of frameset tag is used to specify the amount of spacing between the frames in a frameset. This can take any integer value as an parameter which basically denotes the value in pixel.
    Example:

    <framespacing="20">
    It means there will be 20 pixel spacing between the frames
    
    • Attributes of Frame Tag:

      • name: This attribute is used to give names to the frame. It differentiate one frame from another. It is also used to indicate which frame a document should loaded into.
        Example:

         <frame name = "top" src = "C:/Users/dharam/Desktop/attr1.png" />
         <frame name = "main" src = "C:/Users/dharam/Desktop/gradient3.png" />
         <frame name = "bottom" src = "C:/Users/dharam/Desktop/col_last.png" />
        

        Here we use three frames with names as left center and right.

      • src: This attribute in frame tag is basically used to define the source file that should be loaded into the frame.The value of src can be any url.
        Example:

        <frame name = "left" src = "/html/left.htm" />

        In the above example name of frame is left and source file will be loaded from “/html/left.htm” in frame.

      • marginwidth: This attribute in frame tag is used to specify width of the spaces in pixels between the border and contents of left and right frame.
        Example:

        <frame marginwidth="20">
        
      • marginheight: This attribute in frame tag is used to specify height of the spaces in pixels between the border and contents of top and bottom frame.
        Example:

        <frame marginheight="20">
        
      • scrollbar: To control the appearance of scroll bar in frame use scrollbar attribute in frame tag. This is basically used to control the appearance of scrollbar. The value of this attribute can be yes, no, auto. Where the value no denotes there will be no appearance of scroll bar.
        Example:

        <frame scrollbar="no">
        

      Advantages:

      • It allows the user to view multiple documents within a single Web page.
      • It load pages from different servers in a single frameset.
      • The older browsers that do not support frames can be addressed using the tag.

      Disadvantages: Due to some of its disadvantage it is rarely used in web browser.

      • Frames can make the production of website complicated.
      • A user is unable to bookmark any of the Web pages viewed within a frame.
      • The browser’s back button might not work as the user hopes.
      • The use of too many frames can put a high workload on the server.
      • Many old web browser doesn’t support frames.

      Note: This tag is not supported in HTML5.



      My Personal Notes arrow_drop_up

      Check out this Author's contributed articles.

      If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

      Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




      Article Tags :
      Practice Tags :


      1


      Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.