• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

Part I: HTML > Frames

Chapter 4. Frames

Version 2.0 of Netscape Navigator introduced a new capability for web documents called frames. Frames allow you to divide the main browser window into smaller subwindows (frames), each of which simultaneously displays a separate document. Frame support has since been incorporated into Microsoft Internet Explorer as well.

Two tags are used to make frame documents: <frameset> and <frame>. The <noframes> element provides alternative content for nonframes browsers. This is a requirement for HTML 4.0 and should contain functional content, or a link to it, instead of telling someone to get a browser that supports frames.

A frameset is simply a collection of frames that occupy the browser's window. Column and row definition attributes for the <frameset> tag let you define the number and initial sizes for the columns and rows of frames. The <frame> tag defines what document--HTML or otherwise—initially goes into the frame, and is where you may give the frame a name to use for hypertext link targets.

Here is the HTML source for a simple frame document, which is displayed by the browser in Figure 4.1.

<title>Frames Layout</title>
<frameset rows="60%,*" cols="65%,20%,*">
  <frame src="frame1.html">
  <frame src="frame2.html">
  <frame src="frame3.html" name="fill_me">
  <frame scrolling=yes src="frame4.html">
  <frame src="frame5.html">
  <frame src="frame6.html">
    You are using a browser that does not support frames.
    <a href="frame1.html">Take this link</a> to the first
    HTML document in the set.

Figure 4.1. A simple six-panel frame layout in Netscape

The first thing to notice in the sample document is that Netscape fills the frames in the frameset in order across each row. Second, Frame 4 sports a scrollbar because we told it to, even though the contents may otherwise fit the frame without scrolling. (Scrollbars automatically appear if the contents overflow the frame's dimensions, unless explicitly disabled with scrolling=no.)

Another item of interest is the name attribute in Frame 3. Once named, you can reference a particular frame in which to display a hypertext-linked document. To do that, you add a special target attribute to the anchor (<a>) tag of the source hypertext link. For instance, to link a document called "new.html" for display in our example window Frame 3, which we've named "fill_me", the anchor looks like this:

<a href="new.html" target="fill_me">

If the user selects this link, say in Frame 1, the new.html document replaces the original frame3.html contents in Frame 3.

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint