HTML Frames

The HTML frames are used to divide the browser window into multiple sections, where each section can load a separate HTML document. HTML frames are use to improve appearance and usability of a site. HTML document within frame includes other web pages link can be opened in the desired frame. A collection of frames in the browser window is known as a frameset. The window is divided into frames in a similar way the tables are organized: into rows and columns.

To create frames, we are going to use <frameset> tag instead of body tag. Here the <frameset> defines how to divide the window into frames. The <frameset> tag has two attributes cols and rows.

cols : The cols attribute specifies the number of columns and their width in a frameset. The default value is 100%. The '*' sign is used to allocate the remaining size of the window. For example if we have two frames, then the cols  value will be cols="50%,50%", means each frames will be the size of 50% size of the page. we can also write this as cols="50%,*", at here '*' will take remaining size of the window.
<html>
	<head>
	    <title>Frameset Example 1<title>
	</head>
	<frameset cols="50%, 50%">
  	    <frame src="page1.html" />
            <frame src="page2.html" />
	</frameset>
</html>
And for three frames :
<html>
	<head>
	    <title>Frameset Example 1<title>
	</head>
	<frameset cols="25%, 30%, *">
		  <frame src="page1.html" />
		  <frame src="page2.html" />
		  <frame src="page3.html" />
	</frameset>
</html>

rows : The rows attribute specifies the number of rows and their height in a frameset. The default is 100%. The '*' sign is used to allocate the remaining size of the window. For example if we have two frames, then the rows  value will be rows="50%,50%", means each frames will be the size of 50% size of the page. we can also write this as rows="50%,*", at here '*' will take remaining size of the window.
<html>
	<head>
	    <title>Frameset Example 1<title>
	</head>
	<frameset rows="50%, 50%">
	    <frame src="page1.html" />
	    <frame src="page2.html" />
	</frameset>
</html>
And for three frames :
<html>
	<head>
	     <title>Frameset Example 1<title>
	</head>
	<frameset rows="25%, 30%, *">
	     <frame src="page1.html" />
	     <frame src="page2.html" />
	     <frame src="page3.html" />
	</frameset>
</html>

Some of  the Attributes of <frame> tag :

  • src : The src attribute is used to specify the url of the web document to show on the frame.
  • frameborder : It is used to specify whether display a border or not. The value of the attribute is 0 or 1.
  • name : It is used to specify the frame name.
  • scrolling : Its specify weather scrollbars should be display or not. The values are auto, yes, and no.
  • noresize : Its specify that prevents to resize frame.
  • marginheight : Used to specify the top and bottom margins of frame. The values is in pixels.
  • marginwidth : Used to specify the left and right margins of frame. The values is in pixels.

Some of the Advantages of Frames :
  • Frame Provides technical sophisticated appearance to the web site.
  • It facility to reduce downloading time and improves the usability of the website.
  • Frames generally include navigation link, header or footers, which help user to find and navigate to required information.
  • It separates content of website from navigation elements, which is useful for website maintenance and content modification.

Disadvantages of Frames :

  • The web developer must be track of more HTML documents linked with main frame.
  • It is difficult to print the entire page, which is developed using frame.


Next Topic :