Lesson 5 - Frames

FRAMES

    Frames are very useful if you want to display certain HTML documents all the time while allowing other parts of your HTML document to change accordingly. For example, this page is made up of 2 frames. One contains the menu which stays put even though the contents change on the right. To insert frames, open a new HTML document and insert the following :

<html>
<head>
<titile>Frames</title>
</head>
<frameset cols="160,*">
<frame src="menu.html">
<frame src="main.html">
</frameset>
</html>


    'cols' signifies 'columns', if you want 3 columns then just change '160,*' into '160,160,*' or anything you want. This asterisk '*' denotes that the rest of the space would be the size of the second column. 'frame src' signifies 'frame source' just like <img src>, just enter the file name that you want to open in the respective columns. To differentiate the two columns, you could give them both a name, like this :

<frame src="menu.html" name="menu">
<frame src="main.html" name="main">


    To divide your HTML document into rows instead of columns, just change 'cols' into 'rows' and your page would be divided into half. Within the <frameset></frameset> tags, you could still add a few lines like this :

<frameset cols="160,*" noresize
scrolling="yes" frameborder="0"
marginwidth=0 marginheight=0>


    As the word says, by typing 'noresize', your frames couldn't be resized. If you want your frames to be resizable just don't insert that line. "scrolling' can be turn on or off, by inserting 'yes', 'no' or 'auto'. Try each one and see! 'frameborder' lets you select the thickness of the dividing line, whereas 'marginwidth' and 'marginheight' defines the margins inside the frames.

    To make sure your links would appear in the correct frame, just insert this line into the <a href> tag, this is the reason why it is important to have a name for each and every frame :

<a href="me.html" target="main">Me</a>

    Here's a tough one, to insert 2 columns where one of the frames contains 2 rows, this is what you should do :

<frameset cols="160,*">
<frame src="menu.html" name="menu">
  <frameset rows="200,*">
  <frame src="top.html" name="ontop">
  <frame src="below.html" name="below">
  </frameset>
</frameset>

    Click here to get to Lesson 6 : Tables.


This Page Is Published And Maintained By Wong Kuan Yew
Copyright © 2000 Wong Kuan Yew. All Rights Reserved.
Last Updated: