FREE Subscription to Dr. Dobb’s Digest: Same Great Content, New Digital Edition
Site Archive (Complete)
Email
Print
Reprint

add to:
Del.icio.us
Digg
Google
Furl
Slashdot
Y! MyWeb
Blink
January 01, 2002
The Ins and Outs of Frames

WebReview.com: The Ins and Outs of Frames

Frames. Who would have thought that such a simple idea could stir up so much controversy in the web community? It's almost ancient history now, but come along as we explore the ins and outs of frames.

In the beginning. ...

In the early days of the web, frames did not exist. Web authors had a single stream of HTML with which to create a document, and all our layout options were constrained by that simple model. We also walked to and from work uphill, both ways, and created our pages using coal-fired terminals. And we were happy!

But I digress. Eventually, someone at Netscape grew tired of the single HTML stream model and came up with the idea of frames: several HTML streams combined to create a single document. You could change one HTML stream without affecting the others, and you could cause a link in one stream to open a document in another. It was a great idea but wreaked havoc in the Web world.

It was unavoidable that a document created using frames would be unviewable with older browsers. Sites that started using frames were able to offer great content to people using the latest version of Netscape, but completely alienated folks using other browsers. Webmasters were forced to begin providing two versions of their pages, one for visitors with frame-capable browsers and another for those without. You can still see vestiges of this schism on the Web as some sites continue to offer two views of their content.

In general, this is no longer an issue and you should not fret about using frames to enhance your site. Visitors using Netscape, Internet Explorer, or any HTML 4.0-compliant browser will be able to see your site as you intended, and those who cannot are in dire need of a browser upgrade. Frames are now part of the HTML 4.0 specification and should be used to maximum effect, just like any other HTML feature.

Frame basics

Documents constructed with frames differ from conventional HTML documents in one way: they have no <body> tag. Instead, the <body> tag is replaced by a <frameset> tag. The <frameset> tag, in turn, defines one or more frames that provide the actual content of the document.

Within a <frameset> tag, you may place one or more <frame> tags. Each <frame> tag references an HTML document that will be rendered within the current <frameset>, much like a cell within a table. You can also include additional <frameset> tags, creating a nested arrangement of frames and framesets. This nesting ability is important when creating complex frame layouts and unusual document structures.

As we'll see next week, there are a number of attributes you can apply to the <frame> and <frameset> tags to control the size and position of frames within the top-level document.

Supporting other browsers

In an effort to support browsers that do not support frames, HTML offers the <noframes> tag. This tag can contain any valid HTML content, except frame definitions. Frame-capable browsers ignore the <noframes> tag and its content, while frame-ignorant browsers ignore all the frame tags, rendering only the content of the <noframes> tag.

If you wish, you could put a complete copy (or reasonable facsimile thereof) in the <noframes> tag. More commonly, most webmasters use that space to advise visitors to upgrade their browsers to a frames-capable version in order to view their site. While this once may have caused great consternation among your users, the odds are that you'll get no complaints these days.


Previously in Tag of the Week:

The Single Pixel GIF
Background Images in Tables
Don't Try This At Home

RELATED ARTICLES
No Related Articles
TOP 5 ARTICLES
No Top Articles.
DR. DOBB'S CAREER CENTER
Ready to take that job and shove it? open | close
Search jobs on Dr. Dobb's TechCareers
Function:

Keyword(s):

State:  
  • Post Your Resume
  • Employers Area
  • News & Features
  • Blogs & Forums
  • Career Resources

    Browse By:
    Location | Employer | City
  • Most Recent Posts:
    MEDIA CENTER  more
                                   
    INFO-LINK

    Resource Links: