Creating Colors with Hexadecimal Codes


Creating a color with a hexadecimal code is easier than it first appears. First of all, remember that we are dealing with light, not ink. The absence of all light is darkness (black) and the inclusion of all the colors in the spectrum creates white. In creating a code for our color, we tell the computer how much red light, how much green light, and how much blue light to use when displaying an element on our Web page.

Hexadecimal Numbers

Hexadecimal numbers are numbers expressed in base sixteen. Yes, sixteen. In base sixteen the right-most column is for 1s, the next column to the left is for 16s, the next column is for 256s (16 X 16), and so forth. For digits beyond 9 we use letters of the alphabet. Thus the hexadecimal code for ten is A; the hexadecimal code for eleven is B; the hexadecimal code for twelve is C; the hexadecimal code for thirteen is D; the hexadecimal code for fourteen is E; and the hexadecimal code for fifteen is F.

Number Ranges for Colors

The absence of a color is coded by 00 (zero zero). The maximum value for any of our colors is two hundred and fifty-five. This is coded in hexadecimal as FF. Our color coding is given in the order of red, green, blue. We precede our color coding with a # sign. Therefor, if we wish to code for pure red we use: #FF0000. Pure blue is coded: #0000FF. Bright turquoise is coded: #00FFFF.