The promised bittersweet anecdote and a short explanation of the hexadecimal numbering system are at the bottom of this page. (Promised, that is, if you came here from my home page. If you came here from a search engine, you won't know what I'm talking about.)
HTML lets you specify color as a six-digit hexadecimal number in the form "rrggbb", where "rr" is the red strength, "gg" is the green strength and "bb" is the blue strength. The (hexadecimal) numbers range from 00 to FF, with 00 being the weakest. You specify the background color with the HTML key word "bgcolor". "bgcolor" works in the "body", "table", "tr" and "td" statements.
You specify the text color with the HTML key word "text" in the "body" statement or the HTML "color" key word in the "font" statement. Feel free to click on "View -> Source" to see how I did it on this page.
In most of the examples below, the background color is the first number, and the text color is the second number. For example, the first cell in the table below is pure red (FF0000) with cyan (00FFFF) text; it is labeled "FF0000/00FFFF".
Here are the primary and secondary colors. Note that in HTML (and computers in general) the primary colors are red, green and blue. Yellow, again according to computers, is a secondary color made up of red and green.
Here are the primary and secondary colors at half-strength, with the other color(s) set to 00, which makes them darker. Note that these are not browser-safe. (See below).
Table above reversed - primary and secondary colors at half strength, the other color(s) set to full strength (FF), which makes them lighter. Again, these are not browser-safe.
There are 256 possible strengths for each of the three colors. (0 - 255; 0 counts as a strength.) That means there are 16,777,216 possible color combinations (256 x 256 x 256). This page isn't big enough to show them all.
Besides that, not every browser is set to show that many colors. There are 216 "Browser-Safe" colors. These will look the same on any browser; you are "safe" to use them. They are all the combinations of 00, 33, 66, 99, CC and FF. Six strengths of three colors makes (6 x 6 x 6) or 216 colors. You'll notice this table has just one number, the background color. The text color in the table is either black, white or yellow.
Here's four shades of grey, with five different text colors. In each row the first box is the background color in hex.
Regular numbers are based on tens. When you write "43" it means "4 tens and 3 ones". The regular number system is called "base 10" or "decimal". Hexadecimal is based on sixteens. When you write "43" in hexadecimal it means "4 sixteens and 3 ones". "43" in hexadecimal is thus (4x16) + 3 = 67 in base 10. A single digit in base 10 can have the value 0 through 9. A single digit in hexadecimal can have the value 0 through 15. We don't have a single digit that means "ten", so hexadecimal uses letters. In hexadecimal, A = 10, B = 11, C = 12, and so on to F, which is 15.
The highest possible two-digit number in base 10 is 99. The highest possible two-digit number in hexadecimal is FF. It means "15 sixteens and 15 ones", which is 255 in base 10.
To convert a two-digit hexadecimal number to base 10, multiply the left digit by 16 and add the right digit. For example, "A5" = (10x16) + 5 = 165. To convert a base 10 number between 00 and 255 to a hexadecimal number, divide by 16. Put the answer in the left digit and the remainder in the right digit. For instance, 180/16 = 11 remainder 4, so 180 in base 10 is "B4" in hexadecimal.
(No jokes about "That was 180 I met you" allowed.)
If you want to adjust a color by just a smidgen and don't want to add or subtract in hexadecimal, convert to base 10, add or subtract, and convert back to hexadecimal. Real men, however, will just add and subtract in hexadecimal. Keep reading for an anecdote about adding and subtracting in hexadecimal.
In 1973 I was teaching 8th grade math for $7,000 a year. One week we were studying how to add and subtract in bases other than 10; base 2, base 8, base 12, base 16, base negative 3. It was tough sledding, partly because I wasn't good at explaining things, partly because they had other things on their mind, partly because my discipline was shoddy. One morning a student raised her hand and told the whole class "My grandfather said I would never use this stuff."
I wasn't a genius at explaining things, and I couldn't get a class to stay quiet to save my life, but I was smart enough to know I shouldn't tell her "You're right - I've been wasting everyone's time with busy work."
The next choice, "You're right, Night Light - the most you can hope for is to marry someone who has a steady job and a dental plan" was equally bad.
The last choice, telling her that Gramps was a fool, wasn't going to win me any points either. I knew scientists and engineers used different bases all the time, but I couldn't think of an ordinary job that used them. (This was 1973, remember, the dawn of the computer age, when mainframes were powered by steam and PC's by a crank on the side.)
So, I rambled on about how you just never know and how the average American changes jobs every five years. The next month I beat the average by four years and ten months, having been fired for inability to maintain classroom discipline.
Six months after that, I was working as a Programmer Trainee on an IBM 370 mainframe in San Francisco for $10,000 a year. When one of my programs crashed, the machine spit out what was called a "core dump", on paper, in hex, and I had to figure out what had gone wrong by adding and subtracting in hex. I got a lot of practice adding and subtracting in hex in the first couple of months.
I often wonder what that little girl did with her life, and if she is using hex today. She probably uses "Front Page" and doesn't know you can write raw HTML.
This is a page in my site's section on
Web Design. The section has a page for:
Student Web Site suggestions
Church Web Site suggestions
HTML colors and Hexadecimal numbers
Usability suggestions for any non-profit organization with a volunteer web master.
You might also like the essay, My Adventures as a UU Web Master, a talk I gave to my church about being their web master.