HTML and CSS Reference
In-Depth Information
Figure 3-9
Color addition in the RGB color model
Varying the intensity of the three primary colors creates other colors. Orange, for
example, is created from a high intensity of red, a moderate intensity of green, and a
total absence of blue. CSS represents these intensities mathematically as a set of numbers
called an RGB triplet , which has the format
rgb( red , green , blue )
where red , green , and blue are the intensities of the red, green, and blue components
of the color. Intensity values range from 0 (absence of color) to 255 (maximum intensity);
thus, the color white has the color value rgb(255, 255, 255) , indicating that red,
green, and blue are mixed equally at the highest intensity, and orange is represented
by rgb(255, 165, 0) . RGB triplets can describe 256 3 (16.7 million) possible colors,
which is a greater number of colors than the human eye can distinguish. You can also
enter each component value as a percentage, with 100% representing the highest inten-
sity. In this form, you would specify the color orange with the following values:
rgb(100%, 65%, 0%)
The percentage form is less commonly used than RGB values, but many page design-
ers fi nd it easier to work with.
CSS also allows RGB values to be entered as hexadecimal numbers. A hexadecimal
number is a number expressed in the base 16 numbering system rather than in the com-
monly used base 10 system. In base 10 counting, numeric values are expressed using
combinations of 10 characters (0 through 9); hexadecimal numbering includes six extra
characters: A (for 10), B (for 11), C (for 12), D (for 13), E (for 14), and F (for 15). For values
above 15, you use a combination of those 16 characters. For example, 16 has a hexa-
decimal representation of 10, and a value of 255 is represented as FF in hexadecimal
numbering. The style value for color represented as a hexadecimal number has the form
# redgreenblue
where red , green , and blue are the hexadecimal values of the red, green, and blue
components. Therefore, the color yellow could be represented either by the RGB triplet
or by the hexadecimal
Search WWH ::

Custom Search