The Garsonix guide to HTML

Chapter 8: Using Frames.

Frames are pretty new and only supported by the latest browsers. This is why you have to create a frames and no-frames version of your page if you choose to use them because only a few people can see frames. Frames let you split the screen into several different sections, each displays an html file. They can be really useful and make a site really easy to navigate around. However some people get a bit over excited and display so many different little frames that the page just ends up looking a real mess. I would be careful about how many frames you put on one screen.

Any page that uses frames consists of a main html file that doesn't display and one for each frame on the page. The main html file tells the browser how big each frame is and which html file to load for that frame. Here is an example that creates a page with four frames. Each frame loads an html file called nonsense.htm. This just contains a load of randomly typed characters so you can see the example work.

<HTML>
<HEAD>
<TITLE>Frames.</TITLE>

<FRAMESET COLS="400,*" ROWS="300,*">
<FRAME SRC="nonsense.htm" NAME="one">
<FRAME SRC="nonsense.htm" NAME="two">
<FRAME SRC="nonsense.htm" NAME="three">
<FRAME SRC="nonsense.htm" NAME="four">
</FRAMESET>

</HEAD>

<NOFRAMES>

<BODY>

This part is only printed by browsers that don't support frames, you could include a link here to a no-frames version of your page.

</BODY>

</NOFRAMES>

</HTML>

Display this example.

If in the frameset you only included columns the page would be split into just columns, you could also just have rows. The numbers say how many pixels from the edge the next frame should start. If you wanted 3 columns you would put COLS="200,200,*", the star fills the rest of the screen so you don't have to worry about people with different screen resolutions. When the browser moves down the list of frame src's it fills the top left frame first and then works left to right, top to bottom.

It is important to include the framset in the heading section; that is between the <HEAD> and </HEAD>. If you don't it will work in Internet Explorer 3 but not in Netscape and most other browsers.

If any frame has a link, when clicked this makes that frame hold the page linked to and the rest remain unchanged. It is also possible to make a link open a page but display it in another frame on the page by including the parameter TARGET="name of frame". Here is an example:

<HTML>
<HEAD>
<TITLE>Frames.</TITLE>

<FRAMESET COLS="400,*" ROWS="300,*">
<FRAME SRC="html-eg_23-1.htm" NAME="one">
<FRAME SRC="html-eg_23-2.htm" NAME="two">
<FRAME SRC="nonsense.htm" NAME="three">
<FRAME SRC="nonsense.htm" NAME="four">
</FRAMESET>

</HEAD>
</HTML>

<HTML>
<BODY>

<A HREF="html_1.htm">
This is a link to chapter 1, it will remain in this frame:</A>

</BODY>
</HTML>

<HTML>
<BODY>

<A HREF="html_2.htm" TARGET="four">
This is a link to chapter 2, it will appear in frame four.</A>

</BODY>
</HTML>

Display this example.

The first box is the main file and the next two boxes are the top two frames. Although this example looks a mess you should be able to see the potential of frames. A very good way of using them is to have a thin menu bar which remains there and links to all the pages on your site and displays them in the big main frame.

Some other little things you can do with frames are:
You can make the thick borders separating frames almost disappear by adding FRAMEBORDER="no" to the main frameset tag.
You can also mess about with the margins of each frame. That is how far from the left and top edge stuff appears. You do this by adding MARGINHEIGHT= and MARGINWIDTH= to the frame src tag you want to change the margin on.

As you should see frames are not actually as difficult as they first seem. The only problems with them are that most browsers don't support them and that using them badly can make your page look awful. Used carefully they can make your site much easier to navigate through.

We have now covered most of what there is to know about html, the next chapter covers some of the little extras you can add to your web page to make it stand out from the rest.

Return to contents page.
Go on to next chapter.

A GARSONIX WEB SITE: ©1997.