Web Page Design

26 July 2000

Color Basics

To specify colors in Web pages, you can refer to the predefined set of colors by name. For more control, though, you have to use a six-digit hexadecimal code, specifying the mix of red, green, and blue (RGB) in each color. (Here's a handy hex-to-decimal conversion chart, if ever you need one.)

Think of each color code as three sets of two hexadecimal digits: the first two for red, the second two for green, the last two for blue. Any of these three can be assigned a value from 00 to FF (hex for 255), meaning you have a theoretical limit of 256 x 256 x 256 colors, or 16.7 million -- more than the human eye can distinguish. For practical technical reasons (i.e., not all monitors can show them), it's best to stick to numbers like 00, 11, 22, . . . EE, FF. That still gives you 16 x 16 x 16 colors, or 4096. (It's better still if you stick to 00, 33, 66, 99, CC, and FF.) Some samples:

Code Sample

Your colors don't all have to be 00 or FF: you can use different numbers between them to get different shades. The lower the numbers, the closer to black.

Code Sample

Someone has collected a palette of the 216 most reliable colors to use on Web pages.

You can put the color tags in several places: