home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam    

Book HomeWebmaster in a Nutshell, 3rd EditionSearch this book

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. 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. You can make all visited links in the display magenta with the following attribute for the body tag:

<body vlink="magenta" >

The color names and RGB values defined in the HTML standard are:

aqua (#00FFFF)

gray (#808080)

navy (#000080)

silver (#C0C0C0)

black (#000000)

green (#008000)

olive (#808000)

teal (#008080)

blue (#0000FF)

lime (#00FF00)

purple (#800080)

yellow (#FFFF00)

fuchsia (#FF00FF)

maroon (#800000)

red (#FF0000)

white (#FFFFFF)

The popular browsers go well beyond the HTML 4.0 standard and support the several hundred color names defined for use in the X Window System. Note that color names may contain no spaces; also, the word gray may be spelled grey in any color name.

Colors marked with an asterisk (*) represent a family of colors numbered one through four. Thus, there are actually four variants of blue, named blue1, blue2, blue3, and blue4, along with plain old blue. Blue1 is the lightest of the four; blue4 the darkest. The unnumbered color name is the same color as the first; thus, blue and blue1 are identical.

Finally, if all that isn't enough, there are 100 variants of gray (and grey) numbered 1 through 100. Gray1 is the darkest, gray100 is the lightest, and gray is very close to gray75.

The extended color names are:

aliceblue

darkturquoise

lightseagreen

palevioletred*

antiquewhite*

darkviolet

lightskyblue*

papayawhip

aquamarine*

deeppink*

lightslateblue

peachpuff*

azure*

deepskyblue*

lightslategray

peru

beige

dimgray

lightsteelblue*

pink*

bisque*

dodgerblue*

lightyellow*

plum*

black

firebrick*

limegreen

powderblue

blanchedalmond

floralwhite

linen

purple*

blue*

forestgreen

magenta*

red*

blueviolet

gainsboro

maroon*

rosybrown*

brown*

ghostwhite

mediumaquamarine

royalblue*

burlywood*

gold*

mediumblue

saddlebrown

cadetblue*

goldenrod*

mediumorchid*

salmon*

chartreuse*

gray

mediumpurple*

sandybrown

chocolate*

green*

mediumseagreen

seagreen*

coral*

greenyellow

mediumslateblue

seashell*

cornflowerblue

honeydew*

mediumspringgreen

sienna*

cornsilk*

hotpink*

mediumturquoise

skyblue*

cyan*

indianred*

mediumvioletred

slateblue*

darkblue

ivory*

midnightblue

slategray*

darkcyan

khaki*

mintcream

snow*

darkgoldenrod*

lavender

mistyrose*

springgreen*

darkgray

lavenderblush*

moccasin

steelblue*

darkgreen

lawngreen

navajowhite*

tan*

darkkhaki

lemonchiffon*

navy

thistle*

darkmagenta

lightblue*

navyblue

tomato*

darkolivegreen*

lightcoral

oldlace

turquoise*

darkorange*

lightcyan*

olivedrab*

violet

darkorchid*

lightgoldenrod*

orange*

violetred*

darkred

lightgoldenrodyellow

orangered*

wheat*

darksalmon

lightgray

orchid*

white

darkseagreen*

lightgreen

palegoldenrod

whitesmoke

darkslateblue

lightpink*

palegreen*

yellow*

darkslategray*

lightsalmon*

paleturquoise*

yellowgreen



Library Navigation Links

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











??????????????@Mail.ru