The Latest on HTML Frames

A Look at Whether HTML Frames Have a Place on Websites Today

HTML frames are not this kind of frame
HTML frames are not this kind of frame. Paper Boat Creative / Getty

The HTML <frameset> element was a fixture of website design some years ago, but it is a feature you rarely see on sites these days - and for good reason.

HTML5 Support for Frames

The <frameset> element is not supported in HTML5. This means that if you are coding a webpage using the latest iteration of the language, you cannot use HTML frames in your document. If you want to use a <frameset> in your doucment, you must use HTML 4.01 or XHTML for your page's doctype.

Not to be Confused With iFrames

The HTML <frameset> tag is different than the <iframe> element, which is still supported in HTML5 and which creates an inline frame on a webpage. These frames are often used to display content like Google Maps or YouTube videos on your page.

Targeting HTML Frames

If you are using an older doctype and you do want to use HTML frames, there are some common problem that you should be aware of. One of those issues 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">

In the above frameset, there are two frames, the first is called "nav" and the second is called "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 (this does not work for HTML5, just for really old browsers without frame support), 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">

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:

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

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.

Edited by Jeremy Girard