Key Points
- The HTML frameset tag is deprecated but can still be found on old websites.
- Framesets were used to divide the browser window into separate sections, but they have been replaced byelements styled with CSS.
- Frames in HTML are criticized for being a web accessibility nightmare and causing navigation issues.
- The
- Using the HTML frameset tag in web development is not recommended due to accessibility issues and better alternatives available.
The HTML frameset tag is deprecated. But that doesn’t mean it is completely extinct. You might find it on old websites to this day.
So, is it worth bothering with? Or should you forget this tag ever existed and move on to its modern counterparts?
Let’s talk about this deprecated HTML tag and give it an honorable mention. We’ll look at a few examples of the code in action, which browsers still support it, and we’ll even offer up a few modern alternatives.
What Is the HTML Frameset Tag?
The HTML frameset tag used to be a crucial part of laying out a website. They have been obsolete since HTML 5 came out in 2008. Before the advent of more powerful CSS, you had to construct a page using frames and framesets.
While today, we use <div> or <iframe> tags, and simply style them to get the layout we need. Framesets were used to divide the browser window into separate sections, with each section capable of loading a different HTML document.
They consisted of the <frameset> and <frame> tags. The frameset tag itself would have a few attributes that you could play with to determine the behavior.
Attribute Description cols Specifies the number and sizes of columns. Sizes can be defined using pixel values, percentage values, wildcard symbols, or relative widths. rows Similar to cols
, but defines the number and sizes of rows.border Defines the border width in pixels. frameborder Specifies whether a 3D border should be displayed between frames. Accepts values 1 (yes) or 0 (no). framespacing Defines the space between frames in pixels. The individual frames within the frameset would have their own set of attributes:
Attribute Description src Specifies the file to be loaded in the frame. name Assigns a name to a frame, useful for targeting in hyperlinks. frameborder Controls the visibility of the borders of the frame, overriding the <frameset>
attribute if specified.marginwidth and marginheight Specify the space (in pixels) between the frame’s borders and its content. noresize Prevents the frame from being resized. scrolling Controls the visibility of the scrollbars with values being “yes”, “no”, or “auto”. longdesc Provides a link to a page containing a description of the frame’s content. So, now you know what it is and some of its attributes. Let’s look at how to use the HTML frameset tag with an example.
HTML Frameset Example
Here’s an example of how you can create a simple layout using HTML frames.
<!DOCTYPE html> <html> <frameset cols="50%,50%"> <frame src="frame1.html"> <frame src="frame2.html"> </frameset> </html>
This example creates two vertical frames, each taking up 50% of the window’s width. frame1.html is displayed in the left frame, and frame2.html is displayed in the right frame.
At the top, we have the frameset code creating two 50% columns, with the left one in blue. The bottom shows the resulting webpage. Note how additional CSS styling is done in each HTML file. ©History-Computer.com
Modern Preference over the HTML Frameset Tag
In HTML5, we can use <div> elements styled with CSS to achieve similar layouts. The reason we do this on the modern internet is the separation of the presentation layer from the content layer.
Content is handled by HTML. Presentation is handled by CSS.
With frames, the presentation was being messed with right there in the HTML, which caused all sorts of issues. We’ll dig into those issues in a second, but for now, here is how you would get the same effect with modern code:
<!DOCTYPE html> <html> <head> <style> .column { float: left; width: 50%; height: 100vh; overflow: auto; box-sizing: border-box; } </style> </head> <body> <div class="column" id="frame1"> <!-- Content of frame1.html would go here --> </div> <div class="column" id="frame2"> <!-- Content of frame2.html would go here --> </div> </body> </html>
In this version, the <div> elements with the class column will each take up 50% of the window’s width, similar to the frames in the frameset version.
Note that we’re using the float: left; rule to position the columns side by side, and the box-sizing: border-box; rule to make sure any padding or border added to the columns does not increase their width beyond 50%.
The actual contents of frame1.html and frame2.html would need to be included in these <div> elements directly unless you’re loading the content dynamically with JavaScript.
At first glance, the modern equivalent of the frameset tag appears to require more code to work. So, how is this better? Why were frames so bad that they had to be replaced?
This is where the dark truth about frames comes into play.
Why is the HTML Frameset Tag Not Used Today?
The concept of frames in HTML had been criticized all the way back in 1996 when esteemed web usability expert Jakob Nielsen wrote a column on the matter. Simply put, they are a web accessibility nightmare.
The first issue is that a webpage visitor arriving on a frame from a search engine won’t have access to navigational elements present in another frame on the page. Since separate HTML files are loaded into independent frames, they often will fail to work properly when they aren’t connected, hence the navigation issues.
Another issue is screen readers, and assistive technologies have a difficult time with frames. Since the advent of accessibility requirements, frames have completely fallen out of favor due to their incompatibility with screen readers. There really is no place for them in the modern web.
Frames often will not be able to print properly, either. The challenge of lining up all of the content within frames causes undesirable results when printed. As a result, most of the time, you will only be able to print one frame at a time.
To top it off, an HTML page that uses frames will have problems showing up on small devices. These days, that could be a death sentence for a website, since so much internet traffic is mobile. When your website visitors can’t see your content simply because they’re using a smartphone, you know you have a problem.
With all of the dysfunction, it’s no surprise to find out the W3 Organization has added them to their list of obsolete elements, citing the reason “using them damages usability and accessibility.”
The Modern Replacement to the HTML Frameset Tag
So, is there any modern utility with the unique power of the frameset, but with none of the awful drawbacks? Frames have gone by the wayside.
We already mentioned you can use CSS for styling. But we still need a way to display content from different files or servers on one page. There is one element that can be used for that.
The <iframe> remains healthy. The iframe tag is almost as old as the frameset tag, having been released in 1997.
While the iframe tag used to be more powerful, today, it is only used for a few specific tasks. Typically, you would encounter an iframe when you want to embed a particular function from a website’s API, such as Google Maps or Facebook.
This is great when a developer wants to implement code from another web application without having to store that code on their own server. Instead, they use the iframe to display an API which will then show the end result. It could be a Maps widget or a Facebook news feed, or any number of creative uses.
Wrapping Up: HTML Frameset Tag
While it is still technically supported by many browsers, it comes with a slew of accessibility issues. If you’re building a new website, you would be doing more harm than good by using frames at all, especially since modern browsers will eventually drop support for them completely.
If you’re learning web development, skip the HTML frameset tag. Thanks to improvements in CSS, you can easily create much better layouts without using HTML frames.
The image featured at the top of this post is ©Virrage Images/Shutterstock.com.
Frequently Asked Questions
What does frameset do in HTML?
A frameset lets you create a set of HTML frames. Within each frame, you can load an additional HTML file to display your content. Frames are often used to split a webpage into multiple columns or display areas.
Is frameset still used?
Frameset is deprecated and should not be used, mainly due to web accessibility issues they present.
What is the difference between frame and frameset in HTML?
In HTML, a collection of frames is called a frameset. You can create a frameset by using the <frameset> tag and then defining your <frame> elements within it.
What can I use instead of frameset in HTML5?
You can turn to the <iframe>, which performs a similar function.
Is frameset a container tag?
Yes, the frameset tag is considered a container tag since the individual frame tags are contained within <frameset>