Create a Website With Frames
What are frames?
The Frameset
Frames Source Pages
Frames Scrolling and Stuff
Noframes
Frames Redirection
The Frames Kit
Other Frames Resources
Contact Questions on How to Create a Website With Frames
Create a Website With Frames
What are frames?
Frameset Tag
Frames Kit
Noframes Tag
Frames and Redirection
Other Frames Resources
Frames Scrolling and other Attributes
Frames and Source Pages
Contact Questions on How to Create a Website With Frames
Create a Website with Frames
Websites that use frames are usually built by the 'lone wolves' of the internet.
They are supposedly frowned upon by the experts, though I'm not really sure who those experts are.
Maybe they are the people of the W3C. I've never seen one, but I've seen their work.
Visit their site some time and you'll find manuals and docs filled with a lot of gobble d' gook that only they can understand.
The W3C with all of their good intentions has never been able to convince browser developers to adhere to standards. They probably never will. Maybe they don't understand gobble d' gook either.
So, learn to live with the inconsistencies in browser performance.
Look at this site with an IE browser. Then look at it with a Mozilla browser and you'll see slight differences. Live with it!
If you want to create a website using frames, you must resign yourself to the extra work that is involved to do it properly.
If you want your web pages to be found on the search engines, then be prepared to follow my instructions.
If this is your first website, you should spend some time learning to build static HTML pages before you attempt this tutorial. You probably won't understand anything that is presented if you don't have a knowledge of HTML.
I'm not a designer. I'm not an artist. Some of you are. Those who possess those gifts will be able to take the simple code that I give them and turn it into a masterpiece. Others like myself without the gifts will be able to create a serviceable website.
I recommend that you read through this entire tutorial before you start working on your frames website. Do not type a line of code until you understand redirection and its purpose.
The Frameset
The basic code for a web page built with frames is shown below. Beside it is the code for a basic HTML page.
| Frames Page | HTML Page |
<html>
<head></head>
<frameset>
</frameset>
</html>
|
<html>
<head></head>
<body>
</body>
</html>
|
Notice that when building web pages with frames the body tag is replaced with the frameset tag.
For W3C compliance you should also replace the HTML doctype tag with a frameset doctype similar to the one shown below:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
This doctype should only be used on frameset pages. Content source pages for the website will retain the normal HTML doctype tag.
Defining a Frameset
You need to specify the number of frames, their orientation and the size of each frame window.
Orientation
The orientation of your frameset can be either horizontal, specified with the rows attribute or vertical, specified with the cols attribute.
| Two Equal Rows | Two Equal Columns |
|
<html>
<head></head>
<frameset rows="50/, 50/">
</frameset>
</html>

|
<html>
<head></head>
<frameset cols="50/, 50/">
</frameset>
</html>

|
Number and Size
The number and size of the individual windows within your frameset are specified as shown in the code examples above. Each of the examples is divided into 2 equal size windows specified by 50/ which is an abbreviated form of 50%.
If you wanted 3 cols or rows of equal size the code would be 33/, 33/, 34/. When using percentages, the total should add up to 100.
You can also specify absolute settings or specific dimensions in pixels.
A typical frameset with a 3 cols orientation, with absolute measurements might be defined as: 150, 400, 150 (700 pixel fixed width). If these setting were used with a rows orientation, you would have a frames page with a fixed height of 700 pixels.
If you wanted a fluid design, where the frameset adjusts to the size of the browser window you can use a wildcard (asterick ) as shown. 150, *, 150
Note: When defining rows the measurements are for height. When defining cols the measurements are for width.
Defining frames within frames
Let's call the first 2 code examples shown above, the main frameset. Your next step is to define the individual frame windows within your main frameset.
Individual frame windows are defined with either a second frameset tag for multiple windows or the frame tag for a single frame window.
The website that you are reading was originally built using a 3 row orientation. (I've redesigned it since then)
The top row which contains the website header is a single frame window. The second row is a multiple frameset divided into 3 columns or windows. The bottom row is the single frame footer ( It's empty and only 10 pixels high). The basic code is shown below:
<html>
<head></head>
<frameset rows="70, *, 10">
<frame> */ top row single frame*/
<frameset cols="170, *, 180"> */ second row - 3 columns */
<frame> */ left column - 170 pixels wide*/
<frame> */ middle column - remaining browser width*/
<frame> */ right column - 180 pixels wide*/
</frameset>
<frame> */3rd row - single frame footer*/
</frameset>
</html>
Study the code shown above until you understand the concept of nesting framesets and defining frame windows within the framesets. Note that each individual frame window will eventually be defined by a frame tag.
For an exercise, copy the code into NotePad or your HTML editor. Remove the comments and save the page as test-frames.html. Experiment with changing the sizes and orientation of the defined windows.
When you understand the concepts presented here, you are ready to move on to the next lesson on Source Pages.
Frames and Redirection
The source pages that are targeted into the frames of your website are just plain Ole HTML pages.
If these web pages are rich in content they will be indexed by Google and other search engines.
If someone clicks on the link to one of your source pages , all they would see is a plain Ole HTML page with no frames wrapper.
That's why we need redirection.
When a user clicks on the link to your page we want to redirect it to the frameset and have it appear in the content window.
The Code
We'll need 3 blocks of javascript to make our redirection scheme foolproof.
Main Frameset Page
Place this block of code in the head section of the main frameset page. You should name this page index.html
The code:
<script language="javascript" type="text/javascript">
var fname="content"; //CONTENT AREA FRAME **NAME**
window.onload=function(){
var d=document.location.search;
if(d!='')top.frames[fname].document.location.href=d.substring(d.lastIndexOf('?')+1,d.length);
}
</script>
Make sure that the text between the quotes in this line is the name you've given to your main content window:
var fname="content";
Utility Pages
Let's call pages like the header.html, footer.html and links.html pages utility pages.
If someone clicked a link or accessed these page directly, what would they see?
In the first case they'd see a page with the heading of our website. In the next 2 they'd see the footer of our site and then just the links.
We don't want people to access these pages directly but someone could.
We'll place a block of javascript in the head section of these pages that will redirect them to the main frameset and the default page will appear in the content window.
The code:
<script language="javascript" type="text/javascript">
if(self.location==top.location)self.location="index.html";
</script>
Paste this block of code in the head section of all your utility pages.
Content Pages
We could use the same block of javascript for our content pages and then just let people search for the page they actually accessed.
A better solution would be to send them to the main frameset and have the page they accessed appear in the main content window.
Let's change the last block of code ever so slightly and paste it into the head section of our content pages.
The code:
<script language="javascript" type="text/javascript">
if(self.location==top.location)self.location="index.html?nextpage.html";
</script>
Now if someone accessed this content page it would redirect to the main frameset and nextpage.html would appear in the content window.
Paste this block of code in the head section of all your content pages and change nextpage.html to the name of the content page.
If you don't get anything else from this website, Learn about redirecting directly accessed pages!
Source Pages
When you create a website with frames it is made up of two types of pages.
There are frameset pages that control the structural appearance of the website and there are source pages that are directed into the frame windows of the frameset pages.
Source pages are just plain ole HTML pages. They can contain anything from video presentations to just plain old information and pictures.
As you learned in the previous lesson, every frame window will eventually be defined by a frame tag. You can assign a source page to the frame using 2 methods.
Src Attribute
You can use the src= attribute which is added directly to the desired frame tag. This method is used where the information or content inside of the window will remain the same. Some examples would be the header frame of the page, the navigational frame and as this website uses, the footer frame window.
Using this website as an example, the header window, the links window and the footer window all contain source pages by those names. Those pages are assigned to those windows using the src= attribute.
Here's what the code looks like:
<frame src="header.html"> */ Header window*/
<frame src="links.html"> */Links window*/
<frame src="footer.html"> */footer window*/
Target Attribute
The second way to direct a source page into a desired frame window is by using a link with a target attribute. In order to do this the destination window must have a name.
The name of a frame window is defined using a name attribute within the frame tag. Using this website as an example, the middle frame window in the second row is our target window. It is named simply , middle-frame. the code to name the frame is shown here:
<frame name="middle-frame">
The links in the left window use the target attribute to send the designated pages into the middle frame window. the code is shown here:
<a href="source-page.html" target="middle-frame">Source Page</a>
As you can see the code is just a plain ordinary link with a target attribute added.
Now because you don't want an empty window when the website opens you can also use the src attribute to specify a default page for the frame.
In the code shown below the default page is introduction.html, but when someone clicks on a link in the left window the targeted source page will replace it.
<frame name="middle-frame" src="introduction.html">
Frame Tags
<frameset></frameset>
Used to set orientation, number of rows or columns and size of each.
Attributes:
rows
Horizontal orientation
cols
Vertical orientation
Set values in percentage using forward slash
( Ex. 50/ , 30/, 20/ )
Set values in pixels
( Ex. 150, 400, 150 )
Use wildcards
( Ex. 150, 1*, 150 )
<frame>
Used to define a single frame window.
Attributes:
name
Used to assign a name to frame window for targeting.
src
Used to assign a default document to the frame window.
scrolling
Turn window scrolling on and off
Values:
on, off, auto (Default: auto )
marginwidth
Create space left or right within frame window. Set in pixels.
marginheight
Create space top or bottom of frame window. Set in pixels.
frameborder
Adds or removes border around frame windows. For browser consistency use with the frameset tagThis Practice is Not W3C compliant
Values:
yes, no, 1, 0
( default: yes or 1 )
framespacing
DEPRECATED
Use this when you use the frameborder attribute with the frameset tag and set it to zero. Set framespacing to zero and it will close the gaps between frames on the IE browser. This attribute has been deprecated by the W3C.
noresize
For IE browser only. Stops users from stretching and collapsing frame windows.
<noframes></noframes>
The W3C standard places this tag inside of the main closing frameset tag. I place all of the code from the source page between the tags. Most recommend only the body section of the source page.