In both the HTML document itself and in the style sheet, some attributes take a color for a value. As you may have noticed, colors don’t appear the same from one monitor to the next. You can, however, say a lot with colors. For example, take a page where everything is in seafoam green or watermelon; this page says beach.

Just as with everything else, an HTML way exists to convey information about colors. HTML gives you two choices:

The name of the color (from their approved list) and the hex (hexadecimal) representation of the color. Only 16 named colors exist, so if you are picky about the color you use, then you’ll want to find the hex Representation of that color.

Another thing you should know about colors on the computer is that colors are composed of red, green, and blue, thus the RGB scale. In hex, the first two digits are the amount of red, the next two are green, and the next two are blue. So FF0000 would be pure red. One more thing: 000000 is black; FFFFFF is white. That’s not very intuitive, so you just have to remember when you add color to the screen, it gets lighter.

Unlike paper, which is white when blank, the screen is black when blank. When you indicate the value of an attribute is a color and you use hex representation, you need to precede the hex value with a # ( pound sign). The 16 named colors are listed in Table 1-1 with their hex names. If you know you want a color between two of the colors in the chart, try selecting the value between the two hex values. First, you must know how to count in hex. Hex counts from 1 to 9, then A, B, C, D, E, and F. If you need to add 1 to F, you go to 10 (that’s one-zero, not ten). Try this math problem along with us: 5 plus 6 is B. Plus 5 is 10. Plus 7 is 17. Minus 9 is E. That’s not too hard, is it? Fortunately, we don’t need to multiply or divide in hex!