Using Colors on the Web & HTML color codes
How screens diplay colors
Technically speaking, colors are the way our brain, by use of our eyes, interprets electromagnetic radiation of a wavelenght between 350 and 750 nanometers.
The different wavelengths are seen as different colors, as in the spectrum below. You have probably seen a spectrum like this before. Electromagnetic radiation with a wavelength of over 750 nm is called infra-red, and radiation under 350 nm is ultra-violet.
As discussed in my section about, Color Theory, a computer monitor is made up of thousands of tiny little red, green and blue dots which are grouped three and three. These little dots are close together-- so close that we don't really see them as dots, but rather our eyes mix them up to form one homogenous color.
All colors in the spectrum can be generated with this system of dots. For instace, if the red and green dots are shining at 100% their strength, while the blue not lit at all, you will see the result as a pure yellow color. Each of the three dots can have any value from 0 to 255, which means that the total number of possible colors is 256*256*256 = 16,777,216.
Any color can be represented by a specific combination of three numbers. The yellow mentioned before would have the number 255, 255, 0. The first number represents the red dot, the second represents the green dot, and the last represents the blue. Therefore, a pure blue color would then be 0, 0, 255. The lower the number, the less that color dot is lighted. For instance, by lowering the number for the blue dot-- to the color identified as 0, 0, 100-- you can produce a darker blue. White is produced by the combination of the highest amount of all three colors, so the code for white is 255, 255, 255. Black, on the other hand, is produced by a lack of other colors, so the code for black is 0, 0, 0.
Now to complicate things a bit more, on the web you don't write these numbers just as they are, but instead you write what is called their hexadecimal values. This can be a bit tricky to grasp, so I will try to explain it a bit more in detail.
In our ordinary system of using numbers the base is ten. That is, whenever you reach ten, you add one more digit to your number. And since everything is based in ten, we only need ten digits to represent every possible number. The ten digits are of course 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9. The base of ten goes back to when the system was first developed, and it is based on the fact that humans have ten fingers.
You can say that the hexadecimal system is what our numbers would look like if we had 16 fingers instead of 10. That is, the hexadecimal system uses 16 as the base instead of ten.
The digits in the hexadecimal system are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E and F. It has only recently been agreed that the letters A to F should be used to represent those last six digits. So, let us count from the beginning, and see where we end up. The top row is the ordinary decimal number, and the bottom is its corresponding hexadecimal.
If you continue this up to 255 you find that it corresponds to FF in the hexadecimal system. This means that all numbers from 0 to 255 can be represented with only two digits.
Let's look again at that dark blue color I mentioned before. It had the values of 0, 0, 100. In the hexadecimal system, this would be 0, 0, 64. Usually a zero is added before one-digit numbers (including 0). This means that this dark blue color would be referred to as 00, 00, 64, or 000064. This how all colors are written on the web. For instance, pure yellow is FFFF00.