Specifying colors in HTML can be done in one of two ways; by name or by the Hexadecimal notation.
Named Colors
Syntax:
HTML supports 16 named colors.
HTML Supported Named Colors | |||
---|---|---|---|
Aqua | Black | Blue | Fuchsia |
Gray | Green | Lime | Maroon |
Navy | Olive | Purple | Red |
Silver | Teal | Yellow | White |
RGB Colors Syntax:
The RGB attribute is indicated by a 6-digit hexadecimal number with the first 2 digits representing the amount of Red, the 3rd and 4th digits indicating the amount of Green and the last 2 digits, the amount of Blue.
Hexadecimal is a base 16 number system that uses the digits 0-9 and the letters A-F to represent the numbers 10-15 respectively. Thus, the 2-digit number representing each color component can range from 00 (value 0) through FF (value 255).
If you are not familiar with the mathematical theory behind number systems, not to worry, there is a simple way to convert colors to their hexadecimal components using two of the built-in applets of Windows. The applets you will need are Paint and Calculator. By default, Windows 95 installs both these applications in the Start ¦ Programs ¦ Accessories menu.
From Paint, select Edit Colors from the Options menu, then click the button labeled Define Custom Colors. Your screen should look like this:
In the Calculator, select Scientific from the View menu and you will see this:
In the Color Editor, drag the mouse pointer over the Color Cube until it is on the approximate color you want. The narrow bar to the right represents the 3rd dimension of the cube. When you have the color as close as you can get to what you want in the Color Cube, drag the pointer up and down until the desired color appears in the Color Selection Box. The RGB color components will then appear in the Color Index Numbers in decimal (base 10) format. Take each of these three numbers in order to the Calculator. Making sure that the Number System Conversion is set to Dec, enter the number and then select Hex in the Number System Conversion. This converts the number to Hexadecimal. You can then select Copy from the Edit menu and then paste the number into your HTML document. Make sure that the Number System is reset to Dec each time, and repeat the process for each of the three numbers. In the example shown above, the RGB values of 111, 108, 200 converts to hexadecimal 6f6cc8.
Netscape Colors
What is the difference? | |
---|---|
There really is a difference between the colors in the cells above. The RGB color system gives True Color (24 bit). This means that the full range from 000000 (black) to FFFFFF (white) gives a total of 16,777,216 possible combinations. This is more subtle color differences than the human eye is capable of distinguishing. Even with the 256 color palette, the colors in the palette are selected from the 24 bit model, so the possibility of indistinguishable differences still exists.
Netscape uses a palette that reserves 16 colors for its own use and another 16 colors for Windows. Another 8 colors are removed so that the remaining 216 colors in the palette make an even cube. In order to get even distrubution of colors, each color component uses only the entries 00, 33, 66, 99, CC, and FF. Colors that do not match this palette, are either converted to the nearest equivalent or dithered.
The Netscape Color Cube | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|