11.4. Frame Contents
A frame document contains no displayable content, except perhaps a message for non-frame-enabled browsers. Instead, <frame> tags inside the one or more <frameset> tags (which encapsulate the contents of a frame document) provide URL references to the individual documents that are occupying each frame. Section 11.5, "The <noframes> Tag"
11.4.1. The <frame> Tag
Frames are placed into a frameset column by column, from left to right, and then row by row, from top to bottom, so the sequence and number of <frame> tags inside the <frameset> tag are important.
The browser displays empty frames for <frame> tags that do not have a src attribute. It also displays empty frames if the <frameset> tag calls for more frames than the corresponding <frame> tags define. Such orphans remain empty; you cannot put content into them later, even if they have a target "name" for display redirection. Section 184.108.40.206, "The name attribute"
220.127.116.11. The src attribute
The value of the src attribute for the <frame> tag is a URL of the document that is to be displayed in the frame. There is no other way to provide content for a frame. You shouldn't, for instance, include any <body> content within the frame document; the browser will ignore the frame tags and display just the contents of a <body> tag if it comes first, or vice versa.
The document referenced by the src attribute may be any valid document or any displayable object, including images and multimedia. In particular, the referenced document may itself be composed of one or more frames. The frames are displayed within the referencing frame, providing yet another way of achieving complex layouts using nested frames.
Since the source may be a complete document, all the features of HTML/XHTML apply within a frame, including backgrounds and colors, tables, fonts, and the like. Unfortunately, this also means that multiple frames in a single browser window may conflict with each other. Specifically, if each nested frame document (not a regular HTML or XHTML document) has a different <title> tag, the title of the overall browser window will be the title of the most recently loaded frame document. The easiest way to avoid this problem is to ensure that all related frame documents use the same title.
18.104.22.168. The name attribute
The optional name attribute for the <frame> tag labels that frame for later reference by the target attribute for the hypertext link anchor <a> tag and the <form> tag. This way, you can alter the contents of a frame using a link in another frame. Otherwise, like normal browser windows, hypertext-linked documents replace the contents of the source frame. We discuss names and targets at greater length later in this chapter. Section 11.7.1, "The target Attribute for the <a> Tag"
The value of the name attribute is a text string enclosed in quotation marks.
22.214.171.124. The noresize attribute
Even though you may explicitly set frame dimensions with attributes in the <frameset> tag, users can manually alter the size of a column or row of frames. To suppress this behavior, add the noresize attribute to the frame tags in the row or column whose relative dimensions you do not want users fiddling with. For a two-by-two frame document, a noresize attribute in any one of the four associated frame tags will effectively freeze the relative proportions of all the frames, for example.
The noresize attribute is especially useful for frames that contain fixed images serving as advertisements, a button bar, or a logo. By fixing the size of the frame to contain just the image and setting the noresize attribute, you guarantee that the image will be displayed in the intended manner and that the remainder of the browser window will always be given over to the other frames in the document.
126.96.36.199. The scrolling attribute
The browser will display vertical and horizontal scrollbars with frames whose contents are larger than the allotted window space. If there is sufficient room for the content, the scrollbars disappear. The scrolling attribute for the <frame> tag gives you explicit control over whether the scroll bars appear or disappear.
With scrolling="yes", the browser adds scroll bars to the designated frame even if there is nothing to scroll. If you set the scrolling attribute value to no, scrollbars will never be added to the frame, even if the frame contents are larger than the frame itself. The value auto, supported only by Netscape, works as if you didn't include the scrolling attribute in the tag; Netscape adds scrollbars as needed. To achieve auto behavior in Internet Explorer, simply omit the scrolling attribute altogether.
188.8.131.52. The marginheight and marginwidth attributes
The browser normally places a small amount of space between the edge of a frame and its contents. You can change those margins with the marginheight and marginwidth attributes, each including a value for the exact number of pixels to place around the frame contents.
You cannot make a margin less than one pixel, or make it so large there is no room for the frame contents. That's because like most other HTML attributes, these advise: they do not dictate to the browser. If your desired margin values cannot be accommodated, the browser ignores them and renders the frame as best it can.
184.108.40.206. The frameborder and bordercolor attributes
You can add or remove borders from a single frame with the frameborder attribute. Values of yes or 1 and no or 0 respectively enable or disable borders for the frame and override the value of the frameborder attribute for any frameset containing the frame.
Note that the browsers do react somewhat differently to border specifications. Netscape, for instance, removes an individual border only if adjacent frames sharing that border have borders turned off. Internet Explorer, on the other hand, will remove those adjacent borders, but only if they are not explicitly turned on in those adjacent frames. Our advice is to explicitly control the borders for each frame if you want to consistently control the borders for all frames across both browsers.
With the popular browsers, you also can change the color of the individual frame's borders with the bordercolor attribute. Use a color name or hexadecimal triple as its value. If two adjacent frames have different bordercolor attributes, the resulting border color is undefined. A complete list of color names and values can be found in Appendix G, "Color Names and Values".
220.127.116.11. The title and longdesc attributes
Like most other standard tags, you can provide a title for a frame with the title attribute. The value of the attribute is a quote-enclosed string that describes the contents of the frame. Browsers might display the title, for instance, when the mouse passes over the frame.
If the title attribute isn't quite enough for you, the longdesc attribute can be used. Its value is the URL of a document that describes the frame. Presumably, this long description might be in some alternative media, suitable for use by a nonvisual browser.
Copyright © 2002 O'Reilly & Associates. All rights reserved.