CONTROLLING DOCUMENT BACKGROUNDS


THE BACKGROUND ATTRIBUTE

Recent versions of the proposed HTML 3.0 spec. have added a BACKGROUND attribute to the BODY tag. The purpose of this attribute is to specify a URL pointing to an image that is to be used as a background for the document. In Netscape 1.1, this background image is used to tile the full background of the document-viewing area. Thus specifying:

<BODY BACKGROUND="metal/brushed_aluminum.gif">Document here</BODY>

would cause whatever text, images, etc. appeared in that document to be placed on a background similar to this one. For more choices, take a look at a few examples for ideas on other backgrounds, or check out this helpful guide to various color swatches.

THE BGCOLOR ATTRIBUTE

This attribute to BODY is not currently in the proposed HTML 3.0 spec, but we're working on it. Basically, many people just want to change the color of the background without having to specify a separate image that requires another network access to load. This attribute allows just that. The format that Netscape 1.1 understands is:

<BODY BGCOLOR="#rrggbb">Document here</BODY>

Where "#rrggbb" is a hexadecimal red-green-blue triplet used to specify the background color.


HOW TO CONTROL THE DOCUMENT'S FOREGROUND

Clearly, once you have control of the background, you are going to need to also control the foreground to establish the proper contrasts. The following attributes are also recognized as part of the BODY tag by Netscape 1.1.

THE TEXT ATTRIBUTE

This attribute is used to control the color of all the normal text in the document. This basically consists of all text that is not specially colored to indicate a link. The format of TEXT is the same as that of BGCOLOR.

<BODY TEXT="#rrggbb">Document here</BODY>

THE LINK, VLINK, AND ALINK ATTRIBUTE

These attributes let you control the coloring of link text. VLINK stands for visited link, and ALINK stands for active link. The default coloring of these is: LINK=blue, VLINK=purple, and ALINK=red. Again the format for these attributes is the same as that for BGCOLOR and TEXT.

<BODY LINK="#rrggbb" VLINK="#rrggbb" ALINK="#rrggbb">Document here</BODY>


COMPLETE EXAMPLE

<HTML>

<HEAD>
<TITLE>Color Control Example</TITLE>
</HEAD>

<BODY BGCOLOR="#000000" TEXT="#F0F0F0"
      LINK="#FFFF00" VLINK="#22AA22" ALINK="#0077FF">

This is an example document.  Text is light-gray on black, and
<a href="nowhere.html">anchors</a> are yellow at first,
flashing blue-green when activated, and pale green if already visited.
</P>
</BODY>

</HTML>

STUFF AND BOTHER (THE DETAILS)

To state the obvious, since these color controls are all attributes of the BODY tag, you can only set the colors once for the entire document. You cannot change coloring partially through a document.

In earlier versions of Netscape Navigator, setting a background image meant that none of your document could be displayed until the image was loaded and decoded. Now, with 2.0, text and images load first. When the background is loaded, it pops up behind the text, increasing the perceived speed of document loading.

If you have the Auto Load Images option off, background images will not be loaded. If the background image is not loaded for any reason, and a BGCOLOR was not also specified, then any of the foreground controlling attributes (LINK, VLINK, and ALINK) will be ignored. The idea behind this is that if you didn't get your requested background image, setting your requested text colors on top a the default gray background may well make your document unreadable.


Corporate Sales: 415/937-2555; Personal Sales: 415/937-3777; Federal Sales: 415/937-3678
If you have any questions, please visit Customer Service.

Copyright © 1996 Netscape Communications Corporation