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,*"> </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> |
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,*">
</HEAD>
|
<HTML> <BODY>
<A HREF="html_1.htm">
</BODY> |
<HTML> <BODY>
<A HREF="html_2.htm" TARGET="four">
</BODY> |
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.