Open In App

HTML | <frame> Tag

Last Updated : 17 Mar, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

HTML Frames are used to divide the web browser window into multiple sections 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 used 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:




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


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.




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


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 the column is set in the frameset in the 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 row use the 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 the 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.
      Supported Browser: The browser supported by <frame> tag are listed below:

      • Google Chrome
      • Internet Explorer
      • Firefox
      • Opera
      • Safari

      CSS is the foundation of webpages, is used for webpage development by styling websites and web apps.You can learn CSS from the ground up by following this CSS Tutorial and CSS Examples.



      Like Article
      Suggest improvement
      Previous
      Next
      Share your thoughts in the comments

Similar Reads