On CBSSports.com: Mike Tyson's daughter dies in accident

Avoid frame-based layouts in favor of alternative designs

Tags: Tony Patton, Web Development Zone Newsletter

  • Save
  • Print
  • Recommend
  • 4

Takeaway: Most Web developers view frames as relics and opt for newer technologies such as CSS or AJAX instead. Tony Patton outlines some of the issues with frames and lists benefits of alternative designs.

I recently met with a client to discuss a Web application for internal use. The meeting was going smoothly until he stated a preference for frames. That's right—he preferred frames for site layout. I couldn't remember the last time I actually coded an application with frames. His motives originated with replicating an existing VB application, so it was hard to argue the point. These days, frames are frowned upon, but I had a hard time remembering why. In this article, I explain why you should avoid frames and consider alternate technologies.

The concept

Frames were a cool concept when first introduced many years ago. I can remember coding sites with individual frames for banners, navigation, and site content. The concept is simple if you are unfamiliar with frames. Basically, HTML frames allow you to divide the browser window into individual spaces or frames.

The frame and frameset HTML elements are used to create frame-based layouts. The frame element defines individual spaces or frames. These frames are contained within the frameset element. The cols and rows attributes of the frameset element define the layout of the frames contained within it. The HTML in Listing A creates a sample frameset. The Web Development Zone archive is loaded in the left frame while the Download.com site is loaded in the right frame.

Weekly development tips in your inbox
Keep your developer skills sharp by signing up for TechRepublic's free Web Development Zone newsletter, delivered each Tuesday.
Automatically sign up today!

The scrolling attribute of each frame signals whether the user may scroll within the frame (yes) or not (no), and the noresize attribute says the frame may not be resized so its width is static. The noframes element provides what is displayed in browsers lacking support for frames. There are other options available; refer to an HTML resource for more information.

Loading two Web sites is not the most practical application. Frames have often been used to place a navigation pane on the left or top and content on the right or bottom. This is easily achieved by setting the frame's width (or height) and loading the necessary page(s). The frame concept is simple, but it is viewed with disdain by most Web developers.

Drawbacks

These days, frames are frowned upon by the Web development community. In fact, they are no longer supported in the XHTML 1.1 specification. It is replaced by XFrames. So this may provide one reason to avoid frames, but what about currently supported standards? The following list provides an overview of the reasons frames are not in widespread use:

  • Many Web developers are philosophical when frames are discussed. They say frames violate basic concepts of the Web because it is a large collection of individual pages that may or may not be linked.
  • While most browsers render frames as designed, it is not the case with nontraditional browsing platforms like cell phones, PDAs, and so forth. Frame-based layouts are confusing—if not useless—on these platforms.
  • Search engines have problems processing sites organized with frames. Some search engines, like Google, skip framed content altogether and simply index the noframes content.
  • Coding and design can be a problem when pages are designed for a predefined frame-based area. Problems may arise when these pages are viewed individually and layout is hideous.
  • The browsing experience for users can be irritating with framed sites. Bookmarking such sites often bookmarks the entire frameset and context is ignored, so users find it difficult to bookmark specific content. Another issue is printing, but most browsers allow users to choose to print the entire frameset or individual frames.
  • Frames cause various accessibility problems. The visual layout of frames is difficult to translate to nonvisual browsers. A good rule is to provide textual descriptions of all elements and include content for browsers that don't support frames. The online guidelines provide more details.

Alternative designs

The introduction of frames occurred in the pre-CSS days of the Web. Nowadays, CSS can be used to provide frame-esque designs. The first example can easily be re-created with CSS as Listing B demonstrates.

In this simple example, the background colors of each div are included for demonstration. You can create more robust layouts with CSS; the Yahoo! User Interface Library provides great examples. You may also use AJAX to improve data loading, which is often a reason for using frames (since frames may not have to be reloaded as frequently).

Another presentation option

Frames are relics in most Web developers' eyes. Once beloved, frames became passé as technologies like CSS provided better options. I'd love to hear your opinion of frames. Please share your thoughts and experiences in the article discussion.

And, in case you were wondering, I was able to persuade the client to go with a design featuring CSS to handle page layout.

Miss a column?

Check out the Web Development Zone archive, and catch up on the most recent editions of Tony Patton's column.

Tony Patton began his professional career as an application developer earning Java, VB, Lotus, and XML certifications to bolster his knowledge.

  • Save
  • Print
  • Recommend
  • 4

Print/View all Posts Comments on this article

frames? Jaqui | 08/25/06
persistent headers on "way-too-long" pages GaryB123 | 08/29/06
Probably talking about fixed positioning kpotter@... | 08/29/06
ie does my sites, Jaqui | 09/11/06
here's the css Jaqui | 09/11/06
cool, but... phil@... | 04/04/07
Frames Save Time cklaver@... | 08/29/06
I disagree techrepublic@... | 08/29/06
the issue with dialup and non framed Jaqui | 09/11/06
Why throw away something that works? volker.mehlberg@... | 08/30/06
but i have Problem related with frame in asp.net 2.0_search from 15 days tahirmulani@... | 02/26/08
Why relics are relics info@... | 08/29/06
Think about ajax a little more dlemm@... | 08/29/06
Yeah... but mdandrea@... | 08/29/06
What about iframes (inline frames)? Tavis | 08/29/06
Ahhh... the early days Ole88 | 08/29/06
The problem with flash... dustin@... | 08/29/06
Need to play catch-up Ole88 | 08/29/06
How About PHP? nashsi@... | 08/29/06
I tried ASP with a backend DB... Ole88 | 08/30/06
Another Alternative using PHP Rob Howard | 09/01/06
PHP all the way mindilator@... | 09/05/06
I'll get back into it... Ole88 | 09/05/06
I'd love to... but... number1tech | 08/29/06
and performance? mf556 | 08/29/06
Frames have their place... bbasel@... | 08/29/06
Frames used more than you think? mdbradsh@... | 08/29/06
Well... Colonel Panijk | 09/11/06
Don't criticize blindly, analyze deeply sendahmed@... | 04/04/08
Fantastic Frames (but not simple to code) onefocus99@... | 08/29/06
Nice Site Jeffykins | 08/30/06
Keep in mind... dustin@... | 08/30/06
Includes/Templates tymartist@... | 08/31/06
It all depends on implementation needs Ivy Clark | 09/03/06
as an internet user longwayoff | 10/05/06

What do you think?

White Papers, Webcasts, and Downloads

Article Categories

Security
Security Solutions, IT Locksmith
Networking and Communications
E-mail Administration NetNote, Cisco Routers and Switches
CIO and IT Management
Project Management, CIO Issues, Strategies that Scale
Desktops, Laptops & OS
Windows 2000 Professional, Microsoft Word, Microsoft Excel, Microsoft Access, Windows XP,
Data Management
Oracle, SQL Server
Servers
Windows NT, Linux NetNote, Windows Server 2003
Career Development
Geek Trivia
Software/Web Development
Web Development Zone, Visual Basic, .NET

SmartPlanet

advertisement
Click Here