AlphaZone Computer Resource Center

 

Introduction to Frames  

This is a tutorial for frames. It assumes that you already have some knowledge of basic HTML. If you do not, then try out our Basic Html Tutorial to get you started.

This tutorial will guide you through the different commands and design styles of frames.

Frames are an option within HTML that allow you to take 2 or more pages and place them on one page. 

First, before we get started, you will need five different html pages to work with. You can type them up yourself.

 
testone.html -

<html>
<head><title>This is page number one</title></head>
<body>
<font color="red">This is a test page</font>
<p>
<font color="orange" size="4">Not very exciting, just text.</font>
</body>
</html>

 
 
 
testtwo.html -

<html>
<head><title>This is test page number 2</title></head>
<body>
<font color="blue">This is another test page, but it is better because it has a graphic!<p>
<p>
<image src="designer.gif">
</body>
</html>
 
 

testthree.html -

 
<html>
<head><title>This is test page number 3</title></head>
<body>
<font color="grey"><big>This page is just about the best! The image in this one is centered!</big></font>
<center>
<image src="htmlsmall.gif">
</center>
</body>
</html>
 

 
testfour.html -

<html>
<head><title>This is test page number 4</title></head>
<body>
<center>
<font color="green" size="4">This has got to be the best page because the text is centered as well as the picture.</font>
<p>
<img src="header2.gif">
</body>
</html>
 

 
testfive.html -

<html>
<head><title>This is test page number 5</title></head>
<body>
<center>
<font color="purple" size="4">This is the best page, it has links to all of the other pages, each doing something different! Plus the graphic has a surprise link! It is not, however, a very good surprise!</font>
<p>
<a href="http://www.freethemes.com"><img src="newlogo.gif"></a>
</body>
</html>
 

Alright, there are the five pages you need. Place 1 clipart in each one of them.


Basic Structure

A frames page consists of one or more pages placed on a controlling page. This is the page we will create now.

The first command you must know is the <FRAMESET> command. This is the command that actually creates the frames. You must tell <FRAMESET> if you want columns or rows. You must also tell <FRAMESET> how large each frame should be. So, first set up your basic code:

 
<HTML>
<HEAD><TITLE>This is the Control Page</TITLE></HEAD>
</HTML>
 

Notice that there is no <BODY> command. This command is generally not used on a framed page.
Now it is time to add in the <FRAMESET> command. Add it like so:

<HTML>
<HEAD><TITLE>This is the Control Page</TITLE></HEAD>
<FRAMESET COLS="50%,50%">
</FRAMESET>

</HTML>
 

Notice that the <FRAMESET> command must be closed off.
Now, the Frames are set up to each take up half of the browser. Now for the important part, the pages to add. This will use another command, the <FRAME SRC> command.

<HTML>
<HEAD><TITLE>This is the Control Page</TITLE></HEAD>
<FRAMESET COLS="50%,50%">
<FRAME SRC="testone.html">
<FRAME SRC="testtwo.html">

</FRAMESET>
</HTML>

Now take a look at what you done.
As you can see, each page has taken up half of the space on the page. Don’t like that style? Try rows instead!

 
<HTML>
<HEAD><TITLE>This is the Control Page</TITLE></HEAD>
<FRAMESET ROWS="50%,50%">
<FRAME SRC="testone.html">
<FRAME SRC="testtwo.html">
</FRAMESET>
</HTML>

 

I can see your next question... can I use more then two pages at the same time? Of course!

<HTML>
<HEAD><TITLE>This is the Control Page</TITLE></HEAD>
<FRAMESET ROWS="20%,20%,20%,20%,20%">
<FRAME SRC="testone.html">
<FRAME SRC="testtwo.html">
<FRAME SRC="testthree.html">
<FRAME SRC="testfour.html">
<FRAME SRC="testfive.html">

</FRAMESET>
</HTML>

Pretty confusing looking page isn't it? Remember that when using frames. Too many frames can look confusing to anyone trying to view your page.

Now, there is one problem with the above examples. The effect you want is not what the person on the other end may see if they use a different screen resolution then you. So, try using pixels instead.

<HTML>
<HEAD><TITLE>This is the Control Page</TITLE></HEAD>
<FRAMESET COLS="140, *">
<FRAME SRC="testone.html">
<FRAME SRC="testtwo.html">
</FRAMESET>
</HTML>

 

Not bad, eh? Looks a little more like a table of contents page with a main page next to it. Now, the * that was after the 140 means that whatever space is left over should be taken by the other page.


  No Borders and Scrolling

Now it is time to fiddle around a little bit, to get used to the different ways that you can set up frames. So, try this:

<HEAD><TITLE>This is the Control Page</TITLE></HEAD>
<FRAMESET COLS="*,*">
<FRAMESET ROWS="*,50%">
<FRAME SRC="testone.html">
<FRAME SRC="testtwo.html">
</FRAMESET>
<FRAMESET ROWS="*,50%">
<FRAME SRC="testthree.html">
<FRAME SRC="testfour.html">
</FRAMESET>
</FRAMESET>
</HTML>

As you can see, that created four frames of equal size. Using the columns and rows commands together can allow you to create all sorts of effects. Always remember though, too many frames tend to be confusing. Design suggestion: Use them as a table of contents or site map. Try not to use them too much, or the site looks bad and becomes too difficult to navigate.

Now what if you don't like those borders? Well, let's get rid of them!

<HTML>
<HEAD><TITLE>This is the Control Page</TITLE></HEAD>
<FRAMESET COLS="*,*" >
<FRAMESET ROWS="*,50%">
<FRAME SRC="testone.html" FRAMEBORDER="NO">
<FRAME SRC="testtwo.html" FRAMEBORDER="NO">
</FRAMESET>
<frameset rows="*,50%">
<FRAME SRC="testthree.html" FRAMEBORDER="NO">
<FRAME SRC="testfour.html" FRAMEBORDER="NO">
</FRAMESET>
</frameset>
</HTML>

 

As you can see, there is a new command <FRAME FRAMEBORDER="yes/no">.

The default with frames is that there is a border, however with this command you can rid your page of the borders. So, you must be wondering, why is there an option on <FRAMEBORDER> that says "yes"? Using the "yes" modifier will override any previous command. So, if you don’t want borders except around a particular frame, you can use the combination of commands to get what you want. Let's do an example now.

<HTML>
<HEAD><TITLE>This is the Control Page</TITLE></HEAD>
<FRAMESET COLS="*,*" >
<FRAMESET ROWS="*,50%">
<FRAME SRC="testone.html" FRAMEBORDER="no">
<FRAME SRC="testtwo.html" FRAMEBORDER="no">
</FRAMESET>
<FRAMESET ROWS="*,50%">
<FRAME SRC="testthree.html" FRAMEBORDER="yes">
<FRAME SRC="testfour.html" FRAMEBORDER="no">
</FRAMESET>
</FRAMESET>
</HTML>

 

Now, just one of the frames has borders, while the rest are left empty.
However, it still looks real sloppy. Those scroll bars look strange just floating there.
So, now it is time to get rid of those scroll bars. For this we will use the <FRAME SCROLLING="yes/no/auto"> command. The "yes" command always places the scroll bars in the frame, even if it doesn’t need it. The "no" command leaves out the scroll bars, even if it does need it, and the "auto" command only puts them where they are needed. In this case, we want to get rid of the scroll bars that are on the two frames that use them. We also want to get rid of the borders that are still on. So.....

<HTML>
<HEAD><TITLE>This is the Control Page</TITLE></HEAD>
<FRAMESET COLS="*,*" >
<FRAMESET ROWS="*,50%">
<FRAME SRC="testone.html" FRAMEBORDER="NO">
<FRAME SRC="testtwo.html" FRAMEBORDER="NO" SCROLLING="NO">
</FRAMESET>
<FRAMESET ROWS="*,50%">
<FRAME SRC="testthree.html" FRAMEBORDER="NO" SCROLLING="NO">
<FRAME SRC="testfour.html" FRAMEBORDER="NO">
</FRAMESET>
</FRAMESET>
</HTML>

 

Now the scroll bars are gone. The "auto" setting is the default, so if you put nothing, then that is the one that will be used by the browser.


  No Frames

"Now what about those poor saps who own old browsers that don't know what the heck a <frameset> tag is?", you ask. Well, along with the creation of the frame tags, another tag arose, the <noframes> tag. The browsers that support the frame tags ignore all the content between the <noframes> and </noframes> tags. The browsers that don't support frames, on the other hand, don't know this and simply ignore the tags, displaying the content between them. Below is an example.

<HTML> 
<HEAD><TITLE>This is the Control Page</TITLE></HEAD> 
<FRAMESET ROWS="*,50%"> 
<FRAME SRC="testone.html">
<FRAME SRC="testtwo.html">
</FRAMESET>
<NOFRAMES>

<BODY>

Your browser can't read frames - so you are out of luck!

HAHAHAHAHAHAHA!

</BODY>

</NOFRAMES>
</HTML>

When a browser that supports frames renders this page, it completely ignores all the content between the <noframes> tags. However, when an older browser that doesn't support frames reads this page, it simply ignores all the <frameset>, <frame> and <noframes> tags and so displays all the content between the <noframes> tags.

So what does this mean? Well, for one you can give those with no frame support a message. You can also provide a link to a non-frame version of your site. And those with frame support won't get the message because the browser will ignore it.


  Frame Tutorial: Borders

Now it is time to put the borders back in. This time, however, we are going to make them larger and a different color. In order to do this we will use the <BORDER> and <BORDERCOLOR> commands.

 

<HTML>
<HEAD><TITLE>This is the Control Page</TITLE></HEAD>
<FRAMESET COLS="*,*" BORDER=30>
<FRAMESET ROWS="*,50%">
<FRAME SRC="testone.html">
<FRAME SRC="testtwo.html">
</FRAMESET>
<FRAMESET ROWS="*,50%">
<FRAME SRC="testthree.html">
<FRAME SRC="testfour.html">
</FRAMESET>
</FRAMESET>
<NOFRAMES>
<BODY>
Your browser can't read frames - so you are out of luck! HAHAHAHAHA
</BODY>
</NOFRAMES>
</HTML>

This sets the size for the all of the borders in the frame page. The larger the number, the larger the size of the border. Now, using the <BORDERCOLOR> command we will change the color of the borders. The color modifiers being used can be either from the hex chart or using the actual name of the color. The hex chart gives you a far greater range in your color choices then the word. However, we are going to use simple colors, so in this case we will be using the color red.

<HTML>
<HEAD><TITLE>This is the Control Page</TITLE></HEAD>
<FRAMESET COLS="*,*" BORDER=30 BORDERCOLOR="RED">
<FRAMESET ROWS="*,50%">
<FRAME SRC="testone.html">
<FRAME SRC="testtwo.html">
</FRAMESET>
<frameset rows="*,50%">
<FRAME SRC="testthree.html">
<FRAME SRC="testfour.html">
</FRAMESET>
</FRAMESET>
<NOFRAMES>
<BODY>
Your browser can't read frames - so you are out of luck! HAHAHAHAHAHA
</BODY>
</NOFRAMES>
</HTML>
 

Now, if you want different borders to have different colors then just modify the proper <FRAMESET>

 
 

<HTML>
<HEAD><TITLE>This is the Control Page</TITLE></HEAD>
<FRAMESET COLS="*,*" BORDER=30 BORDERCOLOR="RED">
<FRAMESET ROWS="*,50%">
<FRAME SRC="testone.html">
<FRAME SRC="testtwo.html">
</FRAMESET>
<frameset rows="*,50%" BORDERCOLOR="BLUE">
<FRAME SRC="testthree.html">
<FRAME SRC="testfour.html">
</FRAMESET>
</FRAMESET>
<NOFRAMES>
<BODY>
Your browser can't read frames - so you are out of luck! HAHAHAHAHAHA
</BODY>
</NOFRAMES>
</HTML>

Well, it may look a bit odd, but it gets the point across! Now comes the real important part, links!

 


 

Frames Part Six

You can link the frames any way you like. You can have the new page appear in a particular frame or have it launch a new browser altogether. You can even have this new page over-ride all of the frames and appear frame free. To do this, you must first name each frame. So....

<HTML>
<HEAD><TITLE>This is the Control Page</TITLE></HEAD>
<FRAMESET COLS="*,*" >
<FRAMESET ROWS="*,50%">
<FRAME NAME="FRAME-1" SRC="testone.html">
<FRAME NAME="FRAME-2" SRC="testtwo.html">
</FRAMESET>
<frameset rows="*,50%">
<FRAME NAME="FRAME-3" SRC="testthree.html">
<FRAME NAME="FRAME-4" SRC="testfour.html">
</FRAMESET>
</FRAMESET>
<NOFRAMES>
<BODY>
Your browser can't read frames - so you are out of luck! HAHAHAHAHAHA
</BODY>
</NOFRAMES>
</HTML>

Now each frame has been named. The next part is adding in the links onto the web pages themselves. So, on Page4 go ahead and add this line:

 

This link will <A HREF="testfive.html"> bring up page 5! </A>

 

Add it somewhere after the <BODY> tag. Now, that should bring testfive.html into the frame that testfour.html was in.

Of course, if you want you can send your chosen frame to another frame. To do this you will use the <TARGET> command. Earlier you named each frame with the <NAME> command. Combined with the <TARGET> command you can put the page of your choice to the frame of your choice. So, adjust the line that you just added into testfour.html :

This link will <A HREF="testfive.html" TARGET="FRAME-1"> bring up page 5! </A>

Another command is the <_top> command. This command, used with the <TARGET> command, will cause the page you are linking with to take over the whole page. Unlike most HTML commands, it is important that this command is in lowercase lettering. Usually in HTML it doesn't matter, but in this case it does.

This link will <A HREF="testfive.html" TARGET="_top"> bring up page 5! </A>

 

Another command is the <_blank> command. This command will launch a new browser.

This link will <A HREF="testfive.html" TARGET="_blank"> bring up page 5! </A>


Next we will go over adjusting your margins. Specifically Widths and Heights.


  Frames Tutorial Margin & Height

One of the last commands that we are going to cover is the <MARGINWIDTH> and <MARGINHEIGHT>. This is used mainly for frames containing images. It allows you to set a margin around the image. 1 is the minimum rate, but you may not notice unless you set the number higher. Both commands use pixels. This command it used with the <FRAME> command.

<HTML>
<HEAD><TITLE>This is the Control Page</TITLE></HEAD>
<FRAMESET COLS="*,*" >
<FRAMESET ROWS="*,50%">
<FRAME NAME="FRAME-1" MARGINWIDTH="10" MARGINHEIGHT="10"SRC="testone.html">
<FRAME NAME="FRAME-2" SRC="testtwo.html">
</FRAMESET>
<frameset rows="*,50%">
<FRAME NAME="FRAME-3" SRC="testthree.html">
<FRAME NAME="FRAME-4" SRC="testfour.html">
</FRAMESET>
</FRAMESET>
<NOFRAMES>
<BODY>
Your browser can't read frames - so you are out of luck! HAHAHAHAHAHA
</BODY>
</NOFRAMES>
</HTML>

 

As you can see it created a margin around both sides of the image.

Now it is time to wrap it up!

   


 

Frames: The Exciting Conclusion!

One last frame command. This is the <IFRAME> command. This is a cool command that will put a "floating" frame on your page. The downside to this is that it can only be viewed with IE 4.0 or later (Netscape 5.0 is expected to have iframe support). So, if you have a bunch of Netscape or Opera, etc. users then you shouldn't put anything too important in this frame. The other browsers will ignore the frame entirely.

The proper use of this command is like this:

<IFRAME SRC="http://geocities.datacellar.net/dalpha2" WIDTH=300 HEIGHT=250></IFRAME>

Put that line in the <BODY> of your page. It will create a cool looking frame. You can position this frame wherever you want.

 

Well, that is all for the tutorial. Before we go, here is a couple of quick tips.
First, try not to put too many frames on one page. It looks bad and is confusing for the user.
Secondly, remember that older browsers can't view frames at all. Keep that in mind when trying to reach your audience.

Basic HTML Tutorial | Tables Tutorial | Forms Tutorial | Meta Tags Tutorial | Style Sheets Tutorial

 

1