Specifying Color in HTML
You can specify the color of certain page elements using HTML tags. There are two methods for specifying colors in web documents: by RGB values and by color name.
Specifying Color by RGB Values
Once you’ve identified the red, green, and blue values of your chosen color, you’ll need to translate them to their hexadecimal equivalents in order to enter them into the HTML color tag. These values are written in HTML with the following syntax:
RR stands for the hexadecimal red value,
GG stands for the hexadecimal green value, and
BB stands for the hexadecimal blue value. Using
these values, you can specify any color from the “true
color” space (millions of colors).
Let’s look at an example to put this in context. To set the background color of a document to dark olive green, the complete HTML tag would look like this:
The hexadecimal system
The hexadecimal numbering system is base-16 (as opposed to base-10 for decimal numbers). It uses the following 16 characters:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
A through F represent the decimal numbers 10 through 15.
Converting decimal to hexadecimal
You can calculate hex values by dividing your number by 16 to get the first digit, then using the remainder for the second digit. For example, dividing the decimal number 203 by 16 ...