Webmaster in a Nutshell

Previous Chapter 6 Next
 

6. Color Names and Values

Contents:
Color Values
Color Names

Within Netscape Navigator and Internet Explorer, you can change the colors of various elements of your document. The following table lists some of the tags and attributes that give you color choice.

Element Associated Tag and Attribute
Document background <body bgcolor=color>
All document text <body text=color>
Active hyperlinks <body alink=color>
Visited hyperlinks <body vlink=color>
Regular hyperlinks <body link=color>
Small portion of text <font color=color>

Table cells

<table  bgcolor=color>
<tr  bgcolor=color>
<td  bgcolor=color>
<th  bgcolor=color>

Table borders (Internet Explorer only)

<table  bordercolor=color>
<table  bordercolorlight=color>
<table  bordercolordark=color>
(same  for  <tr>,  <td>,  and  <th>)

6.1 Color Values

In all cases, you may specify the color value as a six-digit hexadecimal number that represents the red, green, and blue (RGB) components of the color. The first two digits correspond to the red component of the color, the next two to the green component, and the last two are the blue component. A value of 00 corresponds to the component being completely off; a value of FF (255) corresponds to the component being completely on. Thus, bright red is FF0000, bright green is 00FF00, and bright blue is 0000FF. Other primary colors are mixtures of two components, such as yellow (FFFF00), magenta (FF00FF), and cyan (00FFFF). White (FFFFFF) and black (000000) are also easy to figure out.

You use these values in a tag by replacing the color with the RGB triple, preceded by a hash (#) symbol. Thus, to make all visited links display as magenta, use this body tag:

<body vlink="#FF00FF">


Previous Home Next
Internet Explorer Tables Book Index Color Names

HTML: The Definitive Guide CGI Programming JavaScript: The Definitive Guide Programming Perl WebMaster in a Nutshell