Frames - Part 2 from Chapter 11 of HTML & XHTML: The Definitive Guide (3/4)
HTML & XHTML: The Definitive Guide, Chapter 11: Frames
The scrolling attribute
The browser displays 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 scrollbars appear or disappear.
scrolling="yes", Internet Explorer, but not Netscape, adds scrollbars to the designated frame even if there is nothing to scroll. If you set the
scrolling attribute value to
no, scrollbars are never 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 only as needed. To achieve
auto behavior in Internet Explorer, simply omit the
scrolling attribute altogether.
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
marginwidth attributes, each including a value for the exact number of pixels to place around the frame's contents.
You cannot make a margin less than 1 pixel or make it so large that there is no room for the frame's 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.
The frameborder and bordercolor attributes
You can add or remove borders from a single frame with the
frameborder attribute. Values of
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, removes 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. You can find a complete list of color names and values in Appendix G.
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.
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.
Created: November 18, 2002
Revised: November 18, 2002