Chapter 8. Color Names and Values

With the popular browsers, you can prescribe the colors of various elements of your document via tag attributes or CSS style definitions.

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 to 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" >

Determining the hexadecimal value for more esoteric colors like “papaya whip” or “navajo white” is very difficult. You can go crazy trying to adjust the RGB triple for a color to get the shade just right, especially when each adjustment requires loading a document into your browser to view the result.

To make life easier, the HTML 4.0 standard defines 16 standard color names that can be used anywhere a numeric color value can be used. For example, you can ...

Get Webmaster in a Nutshell, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.