Приглашаем посетить
Романтизм (19v-euro-lit.niv.ru)

Specifying Custom Colors

Previous Page
Table of Contents
Next Page

Specifying Custom Colors

If none of the named colors imparts the exact hue you're after, you can mix your own custom colors by specifying how much red, green, and blue light should be mixed into each color. It works a little bit like Play-Dohjust mix in the amounts of red, blue, and green you want to get the appropriate color.

The format is #rrggbb, in which rr, gg, and bb are two-digit hexadecimal values for the red, green, and blue components of the color. If you're not familiar with hexadecimal numbers, don't sweat it. Just remember that FF is the maximum and 00 is the minimum, and use one of the following codes for each component:

  • FF means full brightness.

  • CC means 80 percent brightness.

  • 99 means 60 percent brightness.

  • 66 means 40 percent brightness.

  • 33 means 20 percent brightness.

  • 00 means none of this color component.

For example, bright red is #FF0000, dark green is #003300, bluish-purple is #660099, and medium-gray is #999999. To make a page with a red background and dark green text, the HTML code would look like the following:

<body style="background-color:#FF0000; color:#003300">

Although the colors you specify in the <body> tag apply to all text on the page, you can also use either color names or hexadecimal color codes to change the color of a particular word or section of text by using the color style property in conjunction with the <span> tag. This is discussed in Hour 12.

Did you Know?

For a very handy chart showing the 216 most commonly used hexadecimal color codes, along with the colors they create, go to http://www.samspublishing.com.


You should be aware that different computer monitors may display colors in very different hues. I recently designed a page with a beautiful blue background for a client, only to find out later that the president of the company saw it on his computer as a lovely purple background! Neutral, earth-tone colors such as medium gray, tan, and ivory can lead to even more unpredictable results on many computer monitors, and may even seem to change color on one monitor depending on lighting conditions in the room and the time of day.

The moral of the story: Consider sticking to the named colors unless you have precise control over your intended audience's computer displays or you're willing to test your page on various monitors. Of course, testing your pages on different computers is very important, and should be done anyway.


Previous Page
Table of Contents
Next Page