HTML and CSS Reference

In-Depth Information

in the X11 window standard, including
brown
,
pink
,
tan
,
cyan
,
magenta
,
gold
,

and the ever-popular
chartreuse
. For example:

p.crazy { color: chartreuse; }

In general, authors are advised to use colors from the set of 17 names to

ensure that their colors are displayed correctly on the widest variety of devices.

Color values can be precisely deined by giving a triplet of values for the

component colors red, green, and blue (RGB). Each component color is

represented by a number from 0 to 255, or by a percentage from 0 percent

to 100 percent, signifying how much of that color to contributeâ€”from none

to the display's maximum brightness. If all the component colors have the

same value, the resulting color will be along the gray scale. Here are a couple

examples:

.nav li a
{ color: rgb(0,0,51); }
/* very dark blue */

address
{ color: rgb(255,255,255); }
/* white */

Colors can also be speciied using hexadecimal (base 16) notation. he

long-format hexadecimal notation is a hash mark (#) followed by six hexa-

decimal digits. A hexadecimal digit is one of the digits from 0 to 9 or a letter

from a to f, standing in for the numbers 10 through 15. he digits are grouped

into pairs. he irst two digits represent the red component, the second two

represent the green component, and the last two represent blue. Table 3.2

shows the 17 CSS2.1 colors and their corresponding decimal, percentage, and

hexadecimalÂ values.

Table 3.2: CSS2.1 colors

Color Name

RGB Decimal

RGB Percentage

Hexadecimal

black

rgb(0,0,0)

rgb(0%,0%,0%)

#000000

white

rgb(255,255,255)

rgb(100%,100%,100%)

#ffffff

red

rgb(255,0,0)

rgb(100%,0%,0%)

#ff0000

yellow

rgb(255,255,0)

rgb(100%,100%,0%)

#ffff00

green

rgb(0,128,0)

rgb(0%,50%,0%)

#008000

aqua

rgb(0,255,255)

rgb(0%,100%,100%)

#00ffff

continues