Frames in HTML

HTML Frames are used to divide the web browser into multiple sections where each section of frames load  HTML document separately and the collection of frames in the web browser window is known as Frameset which divides and organizes the frames in rows and columns. Let us understand the HTML Frame in detail.

Using HTML Frames

HTML Frame use <frameset> tag  instead of <body> tag on the page of HTML text . frameset tag defines how to divide the browser window into frames and which HTML document shall open into the frame. The Row Attribute of Frameset tag defines the horizontal frames and the Col Attribute in Frameset tag defines the vertical frames.

Basic Example of HTML Frames

Using Row Attributes: Attribute defines the number of horizontal subspaces in a frameset.

Example:

<!DOCTYPE html>  
<html>  
<head>  
    <title>horizontal Frame tag</title>  
</head>  
  <frameset rows="35%,60%,35%">  
    <frame src="/home/aman/Desktop/frames/one.html" >  
    <frame src="/home/aman/Desktop/frames/two.html">   
    <frame src="/home/aman/Desktop/frames/three.html">  
  </frameset>  
</html>

output : 

Using Col Attributes: Attribute defines the number of vertical subspaces in a frameset.

Example:

<!DOCTYPE html>  
<html>  
<head>  
    <title>vertical Frame tag</title>  
</head>  
  <frameset cols="25%,40%,25%">  
    <frame src="/home/aman/Desktop/frames/one.html" >  
    <frame src="/home/aman/Desktop/frames/two.html">   
    <frame src="/home/aman/Desktop/frames/three.html">  
  </frameset>  
</html>

 

output : 

 The frame of HTML 1 :

The frame of HTML 2 :

The frame of HTML 3 :

Mixing column and rows:  using both the Attributes together in one page

Example :

    <!DOCTYPE html>  
    <html>  
    <head>  
        <title>horizontal Frame tag</title>  
    </head>  
      <frameset cols="30%,60%,30%">
      <frameset rows="35%,60%,35%">  
        <frame src="/home/aman/Desktop/frames/one.html" >  
        <frame src="/home/aman/Desktop/frames/two.html">  
</frameset> 
        <frame src="/home/aman/Desktop/frames/three.html">  
<frame src="/home/aman/Desktop/frames/fourth.html">  
      </frameset>  
    </html>

output:

HTML Frame Attributes

<Frameset> Tag Attributes :

 1. cols: Attribute specifies the layout of vertical frames which is used to define the size and number of columns inside the frameset tag. it is separated by a comma with the list of pixels, percentages, and relative lengths.

 2. rows: Attribute specifies the layout of the horizontal frames which is used to define the size and the number of the rows inside the frameset tag. it is separated by a comma with the list of pixels, percentages, and relative lengths.

 3. border: Attribute specifies the width of the border of each frame in pixels and if the value of the border is given zero it depicts no border.

 4. frameborder : Attribute specifies whether a three-dimensional border should be displayed between the frame or not and if the value of the frameborder is given 1 it defines there will be a border and if the value is 0 it depicts no border.

 5. frame spacing: Attributes specifies the amount of spacing between the frames in a frameset and its value is denoted in pixels.

<frame> Tag Attribute :

 1. name: Attribute is allowed to give a name to the frame and indicate which frame a document should be loaded into.

 2. src: Attribute in a frame tag defines the source file name that should be loaded in the frame and the value of the frame can be any URL.

 3. marginwidth : Attribute specifies the width of the space between the left and right of the frame border and its content in pixels.

 4. marginheight : Attributes specifies the height of the space between the top and bottom of the frame and its content in pixels.

 5. longdesc : Attribute allows you to provide a link to another page having a long description of the content of the frame.

Advantages of HTML Frames

  • Multiple documents in a single webpage are displayed in HTML Frames.
  • page loading from the different servers in a single frameset in HTML Frames is easily done.
  • frame tag is used to display the content of the document if the older version browsers do not support it.
  • <noframe> tag used to provide an alternate text for the content if the browser does not support frames.

Disadvantages of HTML Frames

  • the page will be displayed differently on the different systems due to changes in the resolution of the HTML Frames.
  • The browser on the webpage sometimes does not work efficiently.
  • HTML 5 does not support HTML Frames the last version which supports frames is HTML 4.
  • Using HTML Frames too much in the document puts a high workload on the server.
  • smaller devices can not cope with the HTML Frames because their display is not big enough.