Web Design Stuff
HTML Tutorials    CSS Tutorials    Web Hosting   Resources
Create a Web Page 101
Making Web Pages Intro What is a Web Page? Why Make a Web Page? The History of HTML Learn HTML or XHTML?
Basic HTML
Basic HTML Tutorials Basic HTML Necessities How to Make a Web Page How to Edit a Web Page The Basics of HTML Tags Basic HTML Page Structure HTML Attributes
HTML Font Codes
HTML Font Codes Intro HTML Font Color Codes HTML Font Size Codes HTML Font Style Codes HTML Bold/Italic Codes Combining Font Codes
Formatting Text
Formatting Text Intro Making Paragraphs Miscellaneous Formatting Headings & Subheadings Creating Hyperlinks
Using Graphics
Using Graphics on the Web Add Graphics to Your Pages Graphics and Accessibility How to Align Graphics Page Color & Background Graphics as Hyperlinks Horizontal Rules
Creating Tables
HTML Tables Tutorials HTML Table Fundamentals Background & Border Color Table Frames & Rules Table Width and Alignment Cells 1 -Space & Alignment Cells 2 -Row Column Span Cells 3 -Width & Height
Making Lists
HTML Lists Tutorials Bulleted Lists Numbered Lists Definition Lists
HTML Frames
HTML Frames Tutorials Using Frames for Layout Advanced Frame Layouts Putting Hyperlinks in Frames Frame Border Width Color, Margin and Control Problems with Frames SmartFrames: A Solution SSI: An Alternative to Frames
Web Page Forms
Making Feedback Forms A Simple Feedback Form Installing NMS FormMail Debugging Your Setup My Web Host is Out to Lunch User Input Components Text Fields Checkboxes & Radio Buttons Dropdown Menus Push Buttons Layout and Presentation
Basic CSS
Basic CSS Tutorials What is CSS? Why You Should Use CSS How to Use CSS Inline Styles Embedded Style Sheets External Style Sheets Class Selectors ID Selectors Combining Selectors
CSS Properties
CSS Properties Intro Font Styles Width, Height & Spacing Borders Backgrounds Position Float & Alignment Hyperlinks
All About Web Hosting
Hosting Your Own Website What is a Web Host? Your Website's Home Page Building a Website Offline About Free Web Hosting Best Free Web Hosting Commercial Web Hosting How to Get a Domain Name Ecommerce Web Hosting Web Hosting Terminology
Free Web Design Tools
Best Free Website Tools Best Free Text Editors Best Free Graphics Editors Free Website Analysis Tools
Setting Up HTML Kit
HTML Kit Introduction How to install HTML Kit Screenshot Breakdown Basic Configuration Overall Appearance Shortcuts and Startup Editing Window Customizing Toolbars Using the Favorites Tab Making a New Actions Bar Odds and Ends
Free Templates
Free Website Templates Two Column Fixed Width Three Column Liquid Layout Miscellaneous Templates Dynamic Menu Effects Two Column Experimental Terms of Use About These Templates
Website Templates Help
Getting Started Template Zip File Download How to Edit Your Template What to Edit in the HTML How to Add Your Logo Making a Website
Web Design Tips
Web Design Basics Tables vs. Tableless Using Tables for Layout Example Table Layouts World's Crappiest Web Page
Twitter Backgrounds
Twitter Backgrounds Intro Cool Twitter Backgrounds Cool Twitter Backgrounds 2 Plain Twitter Backgrounds Dark Twitter Backgrounds Best Twitter Backgrounds Cute Twitter Backgrounds Music Twitter Backgrounds Music Twitter Backgrounds 2 Twitter Backgrounds 101 TERMS OF USE
All About Web Browsers
What is a Web Browser? Mozilla Firefox Internet Explorer Opera How to Set Up Firefox Top 5 Firefox Extensions
 
Contact
Post Some Feedback Send Me An Email Iron Spider Blog About Iron Spider... Site Conventions
 
 
 

 

Using Frames for Layout

 
This tutorial on using HTML frames to layout your web pages has two versions: the short version and the extended version.

Here's the short version:
DON'T USE FRAMES.

Simple, eh?

Why not, you may ask?

Many reasons. Here are but a few:
  1. Frames are counter-intuitive.
  2. Bookmarking a framed page may not work as the user intended.
  3. Confusion will abound about how to send links leading to your framed pages.
  4. Users may find your 'framed' pages displayed outside of their frameset.
  5. It takes extra effort to make framed pages search engine friendly.
  6. Links to external pages from framed pages must handled carefully.
  7. Frames can look butt-ugly if you don't know what you're doing.
  8. A one-file site menu can just as easily be created using SSI.

Not enough to discourage you? Still intent on using HTML frames to layout your web pages? Alright then, below is the extended version of this tutorial.

First of all, you'll want to know...


What Exactly Are Frames?


HTML frames split your web page into two or more sections within each of which is loaded a distinct and separate web page. Simply put, a web page using frames simultaneously displays multiple web pages in the same browser window.

Why would anyone want to do this?

Good question. Many web sites will sport a header and/or a site menu that remain unchanged as the user navigates from one page to the next loading new text and images into the content area. Using this site as an example, you see the Iron Spider logo at the top of every page and the site menu running down the left side of every page. What essentially changes as you move from one page to the next on this site is the content area which contains the text you are currently reading.

A website that does not use frames (such as this one) requires the user to reload the header and the site menu every time they move from one page to the next. A website that uses frames, on the other hand, allows the user to reload only the content area while the header and site menu do not get reloaded.

Using frames in this manner has a number of advantages:
  1. The header and site menu can remain perpetually within the browser viewport as the user scrolls the content area.
  2. Browsing is faster since only the content area must be reloaded.
  3. The header and site menu can each be updated by editing just a single HTML document. (If you weren't using frames and you wanted to modify the header or site menu, you'd potentially be required to edit each and every page on your website. Be advised, however, that if this is the only reason you are using frames then SSI provides an excellent alternative.)

Basic Frame Layout


Here's a basic frame layout which uses the first four chapters of H. G. Wells War of the Worlds * as the content.

For demonstrational purposes only, I've created a fully functioning mini example of this frame layout below. As you can see, the browser viewport (represented by the green border) is divided into two frames:

redarrow-up (1K)
The MENU FRAME - This frame contains the site menu which remains perpetually within the browser viewport. Clicking on links in this frame will load new pages into the CONTENT FRAME. The MENU FRAME initially loads menu.htm which is a separate and distinct web page. Click here to see menu.htm displayed outside of the frame layout. (Restore frame layout.)
redarrow-up (1K)
The CONTENT FRAME - This frame can be scrolled and contains the main content pertaining to whatever link the user clicks on in the MENU FRAME on the left. The CONTENT FRAME initially loads chapter1.htm which is a separate and distinct web page. Click here to see chapter1.htm displayed outside of the frame layout. (Restore frame layout.)


How to Set Up Frames


We'll use our basic frame layout as our example. As we have already seen, the layout splits the page into two sections and then displays a distinct and separate web page in each section. This layout, however, actually requires three HTML documents to create it. These HTML documents are the frameset document (or the 'mother' page) and the two frame source documents which are loaded by the mother page to create the two frames in our layout. We'll start with the frameset document.


Frameset document


This HTML document sets up the frames to be loaded into the web page. The source code of a frameset document differs from the essential web page structure in that there are no <body>...</body> tags. These are replaced by the <frameset>...</frameset> tags which are used to define the frames. Here's the frameset document source code used to create our basic frame layout:

SOURCE CODE - <frameset> tags highlighted

<html>

<head>
<title>HTML Frames - A Basic Frame Layout</title>
</head>

<frameset cols="25%,75%">
<frame src="menu.htm" name="menu">
<frame src="chapter1.htm" name="content">
</frameset>

</html>



  • Creating Columns ~ The cols attribute is used in the <frameset> start tag to split the page vertically into two or more columns. The value of the cols attribute is a comma-separated list of width percentages totalling to 100% of the browser viewport. Hence, in this example, the cols="25%,75%" attribute/value pair splits the browser viewport into two columns. The first column on the left spans 25% of the full width of the browser viewport while the second column on the right spans the remaining 75%. In this frame layout, each column represents one frame.

    You may also specify the width of a frame column in pixels. The asterisk * is used to specify that other frames will take up the remainder of the available space. Hence a <frameset> start tag with a cols="150,*" attribute/value pair will create two frame columns: a left frame column that spans 150 pixels in width and a right frame column that spans the remainder of the available space.
  • Creating Rows ~ The rows attribute is used in the <frameset> start tag to split the page horizontally into two or more rows. The value of the rows attribute is a comma-separated list of height percentages totalling to 100% of the height of the browser viewport. Hence, in this example, the rows="25%,75%" attribute/value pair splits the web page into two rows. The top row spans 25% of the full height of the browser viewport while the bottom row spans the remaining 75%. In this frame layout, each row represents one frame.

    You may also specify the height of a frame row in pixels. Hence a <frameset> start tag with a rows="150,*" attribute/value pair will create two frame rows: a top frame row that spans 150 pixels in height and a bottom frame row that spans the remainder of the available space.


Frame Source Documents


Each frame in a frame layout displays a distinct and separate web page document. These frame source documents are loaded by using <frame> tags in the frameset document. Note that the frame element is an empty element thereby requiring no end tag. Each <frame> tag in the frameset document corresponds to one framed section on your web page.

Thus, in our basic frame layout, the page is split into two columns using cols attribute in the <frameset> tag and thereby requires two <frame> tags. These are placed in between the <frameset>...</frameset> tags in the frameset document.

SOURCE CODE - <frame> tags highlighted

<html>

<head>
<title>HTML Frames - A Basic Frame Layout</title>
</head>

<frameset cols="25%,75%">
<frame src="menu.htm" name="menu">
<frame src="chapter1.htm" name="content">

</frameset>

</html>



The src attribute is used in each <frame> tag to designate the HTML document to be initially loaded in that particular frame. Hence, in the above example, two frame source documents —menu.htm and chapter1.htm— are initially loaded into the frame layout. In this example, the src attributes use relative addressing and hence all documents (both frameset and frame source) are placed in the same web directory in order to properly function together as a frame layout.

The name attribute is used in each <frame> tag to help with the special handling of hyperlinks required when using frames. The value of the name attribute can be anything you want as long as it's unique.

Each individual frame source document (e.g., menu.htm and chapter1.htm) is written up using the standard or essential web page structure.


*   *   *


Alright then let's crank it up a notch and learn how to make advanced frame layouts including how to make a little framed area in the middle of a standard web page (officially known as an 'inline frame')...





Best Free Stuff
for webmasters

Free Text Editors
Free Graphics Editors
Website Analysis Tools
Free Website Templates

See also:

Best Free Web Hosting

 

If you need a .COM web address, you can get one quick and easy at...

www.GoDaddy.com
INTRO TOP NEXT ~>
 
HTML Tutorials |  CSS Tutorials |  Web Hosting |  Domain Names |  Web Design Resources
Iron Spider © Copyright 2004-2011 Robert Darrell