Book HomeWeb Design in a NutshellSearch this book

Chapter 14. Frames

Contents:

Summary of Frame Tags
Introduction to Frames
Basic Frameset Structure
Frame Function and Appearance
Targeting Frames
Inline (Floating) Frames
Frame Design Tips and Tricks

Frames are a method for dividing the browser window into smaller subwindows, each displaying a different HTML document. This chapter covers the structure and creation of framed documents, controls for affecting their display and function, and some advanced tips and tricks.

14.1. Summary of Frame Tags

In this section, browser support for each tag is noted to the right of the tag name. Browsers that do not support the tag are grayed out. Tag usage is indicated below the tag name. Start and end tags are required unless otherwise noted. "Deprecated" means that the tag or attribute is currently supported but is due to be phased out of the HTML specification and is discouraged from use (usually in favor of similar style sheet controls). "Nonstandard" indicates that the attribute is not part of the HTML specification, but is supported by the major browsers. The attributes listed for each tag reflect those in common use. See "WebTV and Frames" at the end of this chapter for information on WebTV's special handling of framed documents.

A more thorough listing of attributes for each tag, according to the HTML 4.01 specification, appears in Appendix A, "HTML Elements".

<frame>NN 2, 3, 4, 6 MSIE 3, 4, 5, 5.5, 6 HTML 4.01 WebTV Opera5

<frame> (no end tag)

Defines a single frame within a <frameset>.

Attributes

bordercolor="#rrggbb" or color name

Nonstandard. Sets the color for frame's borders (if the border is turned on). Support for this attribute is limited to Netscape Navigator 3.0+ and Internet Explorer 4.0+.

frameborder=1|0 (IE 3+ and W3C 4.0 Spec.); yes|no (NN 3+ and IE 4.0 +)

Determines whether there is a 3-D separator drawn between the current frame and surrounding frames. A value of 1 (or yes) turns the border on. A value of 0 (or no) turns the border off. The default value is 1 (border on). You may also set the frameborder at the frameset level, which may be more reliable.

Because Netscape and Internet Explorer support different values, you need to specify the frameborder twice within <frame> to ensure full browser compatibility, as follows:

frameborder=yes frameborder=1 ...
longdesc=url

Specifies a link to a document containing a long description of the frame and its contents. This addition to the HTML 4.01 specification may be useful for nonvisual web browsers, but it is currently not well supported.

marginwidth=number

Specifies the amount of space (in pixels) between the left and right edges of the frame and its contents. The minimum value according to the HTML specification is 1 pixel. Setting the value to 0 in order to place objects flush against the edge of the frame works in Internet Explorer, but Netscape will still display a 1-pixel margin space.

marginheight=number

Specifies the amount of space (in pixels) between the top and bottom edges of the frame and its contents. The minimum value according to the HTML specification is 1 pixel. Setting the value to 0 in order to place objects flush against the edge of the frame works in Internet Explorer, but Netscape will still display a 1-pixel margin space.

name=text

Assigns a name to the frame. This name may be referenced by targets within links to make the target document load within the named frame.

noresize

Prevents users from resizing the frame. By default, despite specific frame size settings, users can resize a frame by clicking and dragging its borders.

scrolling=yes|no|auto

Specifies whether scrollbars appear in the frame. A value of yes means scrollbars always appear; a value of no means scrollbars never appear; a value of auto (the default) means scrollbars appear automatically when the contents do not fit within the frame.

src=url

Specifies the location of the initial HTML file to be displayed by the frame.

<frameset>NN 2, 3, 4, 6 MSIE 3, 4, 5, 5.5, 6 HTML 4.01 WebTV Opera5

<frameset>...</frameset>

Defines a collection of frames or other framesets.

Attributes

border=number

Nonstandard. Sets frame border thickness (in pixels) between all the frames in a frameset (when the frame border is turned on).

bordercolor="#rrggbb" or color name

Nonstandard. Sets a border color for all the borders in a frameset. Support for this attribute is limited to Netscape Navigator 3.0 and higher and Internet Explorer 4.0.

cols=list of lengths (number, percentage, or *)

Establishes the number and sizes of columns (vertical frames) in a frameset. The number of columns is determined by the number of values in the list. Size specifications can be in absolute pixel values, percentage values, or relative values (*) based on available space.

frameborder=1|0 (IE 3+); yes|no (NN 3+ and IE 4.0+)

Nonstandard. Determines whether 3-D separators are drawn between frames in the frameset. A value of 1 (or yes) turns the borders on; 0 (or no) turns the borders off.

Because Netscape and Internet Explorer support different values, you may need to specify the frameborder twice within <frameset> to ensure cross-browser compatibility, as follows:

frameborder=yes frameborder=1 ...
framespacing=number (IE only)

Internet 3.0 and higher only. Adds additional space (in pixels) between adjacent frames.

rows=list of lengths (number, percentage, or *)

Establishes the number and size of rows (horizontal frames) in the frameset. The number of rows is determined by the number of values in the list. Size specifications can be in absolute pixel values, percentage values, or relative values (*) based on available space.

<iframe>NN 6 MSIE 3, 4, 5, 5.5, 6 HTML 4.01 WebTV Opera5

<iframe> ... </iframe>

Defines an inline (floating) frame within a document with similar placement tags to <img>. This element requires a closing tag. Any content contained within the <iframe> tags will display on browsers that do not support inline frames.

Attributes

align=top|middle|bottom|left|right

Aligns the inline frame on the page within the flow of the text. Left and right alignment allows text to flow around the inline frame.

frameborder=1|0

Turns on or off the displaying of a 3-D border for the inline frame. The default is 1, which displays the border.

height=number

Specifies the height of the inline frame in pixels or as a percentage of the window size. Internet Explorer and Navigator use a default height of 150 pixels.

hspace=number

Nonstandard. Used in conjunction with left and right alignment, this attribute specifies the amount of space (in pixels) to hold clear to the left and right of the inline frame.

longdesc=url

Specifies a link to a document containing a long description of the inline frame and its contents. This addition to the HTML 4.01 specification may be useful for nonvisual web browsers.

marginheight=number

Specifies the amount of space (in pixels) between the top and bottom edges of the inline frame and its contents.

marginwidth=number

Specifies the amount of space (in pixels) between the left and right edges of the inline frame and its contents.

name=text

Assigns a name to the inline frame to be referenced by targeted links.

scrolling=yes|no|auto

Determines whether scrollbars appear in the inline frame (see the explanation of this attribute in <frame>, earlier in this chapter).

src=url

Specifies the URL of the HTML document to display initially in the inline frame.

vspace=number

Nonstandard. Used in conjunction with left and right alignment, this attribute specifies the amount of space (in pixels) to hold clear above and below the inline frame.

width=number

Specifies the width of the inline frame in pixels or as a percentage of the window size. Internet Explorer and Navigator use a default width of 300 pixels.

<noframes>NN 2, 3, 4, 6 MSIE 3, 4, 5, 5.5, 6 HTML 4.01 WebTV Opera5

<noframes> ... </noframes>

Defines content to be displayed by browsers that cannot display frames. Browsers that do support frames ignore the content between <noframes> tags.



Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.