1. Home
  2. Computing & Technology
  3. Web Design / HTML

Frames Tips
Common Problems With Frames

By Jennifer Kyrnin, About.com Guide

Targeting HTML Frames

The most common problem with frames is getting the links to open in the correct frame. This is called targeting. You give your anchor tags a "target" to open their links in. The target is usually the name of the frame.

<frameset rows="40,*">
 <frame src="frame1.html" name="nav">
 <frame src="frame2.html" name="main">
</frameset>

In the above frameset, there are two frames, the first is called "nav" and the second "main". We can imagine that the nav frame (frame1.html) is navigation, and all links within it should open within the main frame (frame2.html).

To do this, you would give the links in frame1 the target of "main". <a href="page2.html" target="main">. But what if you don't want to add the target to every link on your navigation page? You can set a default target in the HEAD of your document. This is called the base target. You would add the line<base target="main">to your head of the frame1.html page, and all links will then open in the main frame.

Frames and Noframes

One of the most misused sections of the frames tag is noframes. This tag allows people with frames incompatible browsers to view your page, and that is the ultimate goal, isn't it?

In a typical frameset, the HTML looks like this:

<frameset rows="40,*">
 <frame src="frame1.html" name="nav">
 <frame src="frame2.html" name="main">
</frameset>

This will create a page with two frames, the top being 40 pixels tall and the bottom being the rest of the page. This would make a nice top navigation bar frameset with the branding and navigation in the 40 pixel frame.

However, if one of your viewers comes to your site on a frames incompatible browser, they get a blank page. The chances of them returning to your site are pretty slim, and to make it viewable by them you need to add four more lines of HTML:

<noframes>
This site is framed, but you can <a href="frame2.html">view a non-framed version</a>.
</noframes>

Because you are pointing to the content portion of your frameset (frame2.html) in the noframes portion of the page, your site becomes accessible.

Keep in mind that while you may be using the 4.x version of your favorite browser, your audience may not want to continually download the latest software. Their machine may not support it, or they may not have room to install a 20+ Meg program on their hard drive. Adding four lines of HTML is a simple solution.

Explore Web Design / HTML
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Web Design / HTML
  4. HTML and XHTML
  5. XHTML
  6. Frames
  7. Styling Frames
  8. HTML Frames - Tips for Using HTML Frames>

©2009 About.com, a part of The New York Times Company.

All rights reserved.