HTML Frames
Posted by admin | Posted in HTML Tutorial | Posted on 11-08-2010-05-2008
0
Frames allow multiple web documents to be displayed inside one browser window at a time.
This means that the actual page has no content of its own but rather specifies n address and that page is displayed there
Frames are now obsolete but are still in use and being used by developers, because they are easy to use and cannot be escaped sometimes.
Frames are most typically used to have a menu in one frame, or a generic header, and content in another frame. When someone clicks a link on the menu that web page is then opened on the content page. Here is a classic example of a basic “index” frameset with a menu on the left and content on the right.
Example:
- <html>
- <head>
- </head>
- <frameset cols=”30%,*”>
- <frame src=”menu.html”>
- <frame src=”content.html”>
- </frameset>
- </html>
Frame Set:
- Here’s the example: Frame Index
· frameset – The parent tag that defines the characteristics of the main page which have the frame. Individual frames are defined inside it.
· frameset cols=”#%, *”- Cols(columns) defines the width that each frame will have. In the above example we chose the menu (the 1st column) to be 30% of the total page and used a “*”, which means the content (the 2nd column) will use the remaining width for itself.
· frame src=”" -The location of the web page to load into the frame.
A good rule of thumb is to call the page which contains this frame information “index.html” because that is typically a site’s main page.
Each frame in a webpage is independent of the others.
The disadvantages of using frames are:
· The web developer must keep track of more HTML documents
· It is difficult to print the entire page
The Frameset Tag
· The <frameset> tag defines how to divide the window into frames, ie in rows or in columns.
· Each frameset defines a set of rows or columns
· The values of the rows/columns indicate the amount of screen area each row/column will occupy.We can specify the values in percentage relative to the web page or in pixels.
The Frame Tag
· The <frame> tag defines which HTML document to display into each frame
In the example below we have a frameset with two columns. The first column is set to 25% of the width of the browser window. The second column is set to 75% of the width of the browser window. The HTML document “frame_a.htm” is put into the first column, and the HTML document “frame_b.htm” is put into the second column:
| <frameset cols=”25%,75%”> <frame src=”frame_a.htm”> <frame src=”frame_b.htm”> </frameset> |
Note: The frameset column size value can also be set in pixels (cols=”200,500″), and one of the columns can be set to use the remaining space (cols=”25%,*”).
Important: You cannot use the <body></body> tags together with the <frameset></frameset> tags! However, if you add a <noframes> tag containing some text for browsers that do not support frames, you will have to enclose the text in <body></body> tags! See how it is done in the first example below.
