A Quick Lesson on Hexadecimals

A background color that has 0 red, 0 blue, and 0 green would be black. A color that has 255 red, 255 blue, and 255 green (that's 100 percent of each) would be pure white.
 Okay, that explains the "triplet" part of "hexadecimal triplet." Now let's explain the "hexadecimal" part. You see, JavaScript doesn't like "normal" numbers, such as 255. It prefers a different numbering system known as hexadecimal. The system we humans commonly use is known as decimal. Many computer programs can convert decimal numbers to hexadecimal for you. There is a brief tutorial on how to do that following immediately this section.

The value of document.bgColor is the hexadecimal triplet that defines the current page's background color. A possible value would be “000000,” or pure black. Note that the long hexadecimal number is, in fact, three 2-digit hexadecimal numbers in a row. The leftmost two digits represent the Red value, the second two represent Green, and the rightmost two represent Blue. Another possible value would be "FFFFFF", which is pure white. Likewise, "FF0000" would be pure red. You can, in turn, alter the current background color by assigning a new hexadecimal triplet to document.bgColor. For example, regardless of what the current page's background color is, the JavaScript assignment document.bgColor = "#00FF00" changes the background to pure green. NOTE: the hash mark (#) in the above assignment, it is traditional to place the hash mark in front of a hexadecimal number. If you leave it out of the assignment, it will still work. But note that if you retrieve the value of document.bgColor, it will contain a hash mark preceding the hexadecimal triplet regardless of whether you included it or not.

Along these same lines, document.fgColor will contain the hexadecimal triplet that represents the text color. And, similarly, assigning a new value to this property will change the text color.

Manipulating all of these possible combinations is a pain. Although this is the only way to fine-tune the exact color you will use, JavaScript does provide a shortcut. Instead of the hexadecimal triplet, you can assign a string literal specifying one of JavaScript's built-in color names. JavaScript has a long list of predefined colors, such as "aliceblue" and "crimson" and “palegreen.” Therefore, instead of using an assignment such as this:

document.bgColor ="#000000"

you can write this instead:

document.bgColor="black"

Hexadecimals - How to

Hexadecimal is a base-16 numbering system, which contains the base values 0 – F. That is, beyond 9 comes A, B, C, D, E, and F. Your common decimal system uses base-10 numbering, which only has the base values 0 – 9. Converting a decimal number, which you're used to, to a hexadecimal number, requires some addition and multiplication.

Here you're only considering 2-digit hexadecimal numbers that represent red, green, or blue values (although in decimal, these same values would be 3 digits long because decimal has fewer possible values for one digit to hold). To convert a hexadecimal number to decimal, then, use the following formula:

(left-hand hexadecimal digit * 16) + (right-hand hexadecimal digit)

HEXADECIMAL CONVERSION DECIMAL VALUE
05 (0 * 16) + (5) 5
1A (1 * 16) + (10) 26
C5 (12 * 16) + (5) 197
FF (15 * 16) + (15) 255

NOTE: that a hex digit of A = 10, B = 11, etc., to F = 15

This should give you enough knowledge to guesstimate hex values for the color specification; from there, you can fiddle with the exact values to create the exact color you're looking for.