The Latest on HTML Frames

Do they have a place on websites today?

Not an HTML frame but rather an empty frame on a gallery wall

Paper Boat Creative / Getty Images

As web designers, we all want to work with the latest and greatest technologies. Sometimes, however, we are stuck working on legacy pages that, for one reason or another, cannot be updated to current web standards. You see this on certain software applications that may have been custom created for companies many years ago. If you are tasked with the job of working on those sites, you will undoubtedly get your hands dirty working with some old code. You may even see aor two in there!

The HTML 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. Let's look at where support is today, and what you need to know if you are forced to work with frames on a legacy website.

HTML5 Support for Frames

TheHTML5. 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 aHTML 4.01 or XHTML for your page's doctype.

Because frames are not supported in HTML5, you will not be using this element on a newly built site. This is something you will only encounter on those aforementioned legacy sites.

Not to Be Confused With iFrames


Targeting HTML Frames

OK, so everything about frames being obsolete having been said, what happens if you do need to work with these old pieces of HTML?

If you are using an older doctype and you do want to use HTML frames, there are some common problems 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.

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". 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

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 — so you can't try to cram this into HTML5 to make it work. Nice try, but no luck.), and that is the ultimate goal, isn't it?

In a typical frameset, the HTML looks like this:

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 view a non-framed version.

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 latest 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.

mla apa chicago
Your Citation
Kyrnin, Jennifer. "The Latest on HTML Frames." ThoughtCo, Jul. 31, 2021, Kyrnin, Jennifer. (2021, July 31). The Latest on HTML Frames. Retrieved from Kyrnin, Jennifer. "The Latest on HTML Frames." ThoughtCo. (accessed June 8, 2023).