Sams Teach Yourself Web Publishing with HTML and CSS in One Hour a Day (5th Edition)

Notice that all the frames in today's lesson have thick borders separating them. There are a number of attributes that can be set to control the appearance of frame borders or prevent them from appearing altogether.

Start with the <frame> tag. By using two attributes, bordercolor and frameborder, you can turn borders on and off and specify their color. You can assign bordercolor any valid color value, either as a name or a hexadecimal triplet. frameborder takes two possible values: 1 (to display borders) or 0 (to turn off the display of borders).

Note

If you turn off the border, frames-compatible browsers won't display its default three-dimensional border. However, a space will still be left for the border.

HTML 4.01 currently lists only the frameborder attribute. The bordercolor attribute qualifies as an extension.

For example, the following code adds a deep red border (defined by #cc3333) around the middle frame in the frameset:

<html> <head> <title>The frame Tag</title> </head> <frameset rows="*,*,*"> <frame src="/books/2/631/1/html/2/document1.html"> <frame frameborder="1" bordercolor="#cc3333" src="/books/2/631/1/html/2/document2.html"> <frame src="/books/2/631/1/html/2/document3.html"> </frameset> </html>

Although HTML 4.01 doesn't provide either of these attributes for the <frameset> tag, you can use both of them to define default values for the entire frameset in current browsers.

Of course, there's room for confusion when colored borders are defined. In the following frameset definition, a conflict arises because the two frames share a single common border, but each frame is defined to have a different border color with the bordercolor attribute:

<html> <head> <title>Conflicting Borders</title> </head> <frameset frameborder="0" rows="*,*,*"> <frame frameborder="1" bordercolor="yellow" src="/books/2/631/1/html/2/document1.html"> <frame bordercolor="#cc3333" src="/books/2/631/1/html/2/document2.html"> <frame src="/books/2/631/1/html/2/document3.html"> </frameset> </html>

In addition, the frameset is defined as having no borders, but the first frame is supposed to have a border. How do you resolve this problem? You can apply three simple rules:

  • Attributes in the outermost frameset have the lowest priority.

  • Attributes are overridden by attributes in a nested <frameset> tag.

  • Any bordercolor attribute in the current frame overrides previous ones in <frameset> tags.

Additional Attributes

Table 14.1 shows a few extra attributes for the <frame> tag. These attributes can give you additional control over how the user interacts with your frames. Other attributes control margins or spacing between frames and whether scrollbars appear when required.

Table 14.1. Control Attributes for the <frame> Tag

Attribute

Value

Description

frameborder

1

Displays borders around each frame (default).

frameborder

0

Creates borderless frames.

longdesc

URL

Specifies a URL that provides a longer description of the contents of the frameset. Primarily used with nonvisual browsers.

marginheight

pixels

To adjust the margin that appears above and below a document within a frame, set marginheight to the number indicated by pixels.

marginwidth

pixels

The marginwidth attribute enables you to adjust the margin on the left and right sides of a frame to the number indicated by pixels.

name

string

Assigns a name to the frame for targeting purposes.

noresize

 

By default, the users can move the position of borders around each frame on the current screen by grabbing the borders and moving them with the mouse. To lock the borders of a frame and prevent them from being moved, use the noresize attribute.

scrolling

auto

(Default) If the content of a frame takes up more space than the area available, frames-compatible browsers automatically add scrollbars to either the right side or the bottom of the frame so that the users can scroll through the document.

scrolling

no

Setting the value of scrolling to no disables the use of scrollbars for the current frame. (Note that if you do this but the document contains more text than can fit inside the frame, users won't be able to scroll the additional text into view.)

scrolling

yes

If you set scrolling to yes, scrollbars are included in the frame even if they aren't required.

src

URL

Specifies the URL of the initial source document that appears in a frame when the frameset first opens in the browser.

Категории