Section 11.4. Frame Contents


11.4. Frame Contents

A frame document contains no displayable content, except perhaps a message for nonframes-enabled browsers. Instead, <frame> tags inside one or more <frameset> tags (which encapsulate the contents of a frame document) provide URL references to the individual documents that occupy each frame. [<noframes>, 11.5]

11.4.1. The <frame> Tag

The <frame> tag appears only within a <frameset> . Use it to set, via its associated src attribute, the URL of the document content that initially gets displayed inside the respective frame.

<frame>

Function

Defines a single frame in a <frameset>

Attributes

bordercolor , class , frameborder , id , longdesc , marginheight , marginwidth , name , noresize , scrolling , src , style , title

End tag

</frame> ; rarely included in HTML

Contains

Nothing

Used in

frameset_content



Browsers place the frame contents into the frameset column by column, from left to right, and then row by row, from top to bottom. Accordingly, 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 src attributes. It also displays empty frames if the <frameset> tag calls for more frames than the corresponding <frame> tags defineif your frame document calls for three columns and you provide only two frames, for example. Orphan frames remain empty, and you cannot put content into them later, even if they have a target name or id for display redirection. [The name and id attributes, 6.3.1.3]

11.4.1.1. The src attribute

The value of the src attribute for the <frame> tag is the 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 ignores the frame tags and displays 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.

Because 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 is 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.

11.4.1.2. The name and id attributes

The optional name attribute for the <frame> tag labels that frame for later reference by a target attribute for the anchor ( <a> ) tag and the <form> tag. This way, you can alter the contents of a frame using a hyperlink in another frame. Otherwise, like normal browser windows , linked documents replace the contents of the source frame. We discuss names and targets at greater length later in this chapter. [The target Attribute for the <a> Tag, 11.7.1]

Similarly, the id attribute uniquely identifies a frame, but the browsers do not support its use for target redirection, even though they do support id 's use as a hyperlink target in many other HTML and XHTML tags.

The value of the name or id attribute is a text string enclosed in quotation marks.

11.4.1.3. 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 example, for a two-by-two frame document, a noresize attribute in any one of the four associated frame tags effectively freezes the relative proportions of all the frames.

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 is displayed in the intended manner and that the remainder of the browser window is always given over to the other frames in the document.

11.4.1.4. The scrolling attribute

The browser displays vertical and horizontal scroll bars with frames whose contents are larger than the allotted window space. If there is sufficient room for the content, the scroll bars disappear. The scrolling attribute for the <frame> tag gives you explicit control over whether the scroll bars appear or disappear.

With scrolling="yes" , all the popular browsers except Netscape add scroll bars to the designated frame even if there is nothing to scroll. If you set the scrolling attribute value to no , scroll bars are never added to the frame, even if the frame contents are larger than the frame itself. The value auto , the default, works as though you didn't include the scrolling attribute in the tag.

11.4.1.5. 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'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.

11.4.1.6. The frameborder and bordercolor attributes

With some earlier versions of Internet Explorer, you could add and remove borders from a single frame with the frameborder attribute. Values of yes or 1 and no or respectively enable or disable borders for the frame and override the value of the frameborder attribute for any frameset containing the frame. Don't use it.

With all the popular browsers except Opera, 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.

11.4.1.7. 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, you can use the longdesc attribute. 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.



HTML & XHTML(c) The definitive guide
Data Networks: Routing, Security, and Performance Optimization
ISBN: 596527322
EAN: 2147483647
Year: 2004
Pages: 189
Authors: Tony Kenyon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net