HTML COLOR PRIMER for PETER's Sake 1/22/2003 ====================================================================== Computer Numbering Systems Number Base Equivalance Table Base 10 Base 2 Base 16 Decimal Binary Hexadecimal 0 0000 0 1 0001 1 2 0010 2 3 0011 3 4 0100 4 5 0101 5 6 0110 6 7 0111 7 8 1000 8 9 1001 9 10 1010 a or A 11 1011 b or B 12 1100 c or C 13 1101 d or D 14 1110 e or E 15 1111 f or F 4 bits or binary digits are one hexadecimal digit also called one nibble. 8 bits are one byte or two hexadecimal digits or two nibbles. -------------------------------------------------------------------------- Range of Values for Decimal 1 nibble 0 to 15 1 byte 0 to 255 2 bytes 0 to 65,535 3 bytes 0 to 16,777,215 Binary 1 nibble 4 bits 0000 to 1111 1 byte 8 bits 00000000 to 11111111 2 bytes 16 bits 0000000000000000 to 1111111111111111 3 bytes 24 bits 000000000000000000000000 to 111111111111111111111111 Hexadecimal 1 nibble 0 to f 1 byte 2 nibbles 00 to ff 2 bytes 4 nibbles 0000 to ffff 3 bytes 6 nibbles 000000 to ffffff Powers of 2 1 nibble 2^4 different values or 2^4 -1 maximum value 1 byte 2^8 different values or 2^8 -1 maximum value 2 bytes 2^16 different values or 2^16 -1 maximum value 3 bytes 2^24 different values or 2^24 -1 maximum value -------------------------------------------------------------------------- HTML Color Scheme There are three Composite Primary Colors, Red, Green and Blue. The acronym RGB means Red, Green and Blue. Use one byte of computer memory for each of the three colors. Thats 3 bytes or 24 bits for the three colors combined. That generates 16,777,215 different possible colors. +----------+----------+----------+ | Byte 1 | Byte 2 | Byte 3 | Byte # +----------+----------+----------+ | Red | Green | Blue | Color +----------+----------+----------+ | 00 to ff | 00 to ff | 00 to ff | Hex Value +----------+----------+----------+ A hex value of: 00 is the total absence of a color (none of a color is present), zero intensity. 40 is 1/4 of a color is present, 3/4 of that color is absent. 80 is half a color is missing, and half is present. c0 is 3/4 of a color is present, 1/4 of that color is absent. ff is the total presence of a color (all of the color possible), maximum intensity. Fundamental or Common Color Examples: 000000 = black; no red, no green, no blue, total absence of all three colors. ffffff = white; all red, all green, all blue, total presence of all three colors. ff0000 = red; all red, no green, no blue. 00ff00 = lime (bright green); all green, no red, no blue. 0000ff = blue; all blue, no red, no green. ffff00 = yellow; all red, all green, no blue. ff00ff = fuchsia (aka magenta); all red, no green, all blue. 00ffff = cyan (aka aqua); no red, all green, all blue. 404040 = dark gray; 1/4 red, 1/4 green, 1/4, blue. 808080 = gray; 1/2 red, 1/2 green, 1/2 blue. c0c0c0 = light gray; 3/4 red, 3/4 green, 3/4 blue. ffa500 = orange; all red, a lot of green, no blue (compare to yellow above). a52a2a = brown; a lot of red, a little green, a little blue. and millions of combinations more! ---------------------------------------------------------------------------- HTML Number Encoding Standard How does your browser know when it sees 10 on your HTML page, that you mean 10 decimal and not 10 hexadecimal? This is where the number sign or pound sign comes in: #10 is a hexadecimal number. 10 is a decimal number, not binary or hex. #102030 is a hex value, 102030 is decimal. When specifying colors, numbers should be enclosed in double quotes, so: "#102030" is a hex number string. ---------------------------------------------------------------------------- HTML Tags with Color Specifications body bgcolor="#ffffff" = BackGround color for the page will be white. table bgcolor="#0000ff" = BackGround color of the table will be blue. font color="#ff0000" = The text will be in red letters. ---------------------------------------------------------------------------- Named Color Specifications in HTML How would a person know what color "#d3457f" would be? Wouldn't it be nice if you wanted a lightreen color that you could just type in "lightgreen"? A group of people that defines what HTML is and is not, did just that. They came up with a list of 140 common named colors just for our ease of use. body bgcolor="dodgerblue" is easy compared to body bgcolor="#1e90ff". I'm guessing that most people can't name anywhere near 140 different colors from memory. So 140 is a lot of colors. ---------------------------------------------------------------------------- Happy HTMLing By Jim Shook 1/22/2003