Tutorial 23: The Font of Foulness, Part II: Many Faces, Many Colors - HTML with Style
The color is specified in the form of a hash sign (#) followed by six hexadecimal digits. The first pair of digits represent the amount of red, the second pair the amount of green, and the third pair the amount of blue used to mix the color required. This way of specifying colors is exactly identical to one of the syntaxes used in CSS, which we covered in Tutorial 8.
What naturally follows from the above is that (drumroll...) you can use the CSS color property to replicate the behaviour of the COLOR attribute. So the following statements will have the same visual effects on both Internet Explorer and Navigator:
<P><FONT COLOR="#FF0000">This is some text. It is red.</FONT></P> <P STYLE="color: #FF0000">This is some text. It is also red.</P> <P STYLE="color: rgb(255,0,0)">This is some text. It, too, is red.</P> <P STYLE="color: rgb(100%,0,0)">This is some text. Guess what? It's red.</P>
This is some text. It is red.
This is some text. It is also red.
This is some text. It, too, is red.
This is some text. Guess what? It's red.
Since we're on the subject of color, remember back in Tutorial 8 when I mentioned that it's a bad idea for you to specify text colors without specifying background colors as well? This wasn't just a random observation. People have made this mistake a whole lot since color was introduced to the Web, and other people have told them not to do it a whole lot, and the first people haven't listened and still do it. A whole lot. But this is a tutorial that teaches HTML and CSS, not the pitfalls of using bright ochre text on a diseased lilac background. But since the problems of people with no taste in color predate CSS, you must be wondering how background colors were specified before CSS. Funny you should mention that...