Colors in HTML – web page color codes and names

1. Home
2. HTML
3. Colors in HTML – web page color codes and names

Okay, here is the much awaited color session.

Colors for HTML pages can be specified by their names or hexadecimal values. The main advantage with color names is that they are easy to remember. The disadvantages are that they are not displayed equally among browsers and you are limited to only 140 colors (since there are only 140 color names!). If you want to specify colors that are browser compatible you have to use their hexadecimal values.

Internet Explorer introduced 16 color names, the rest were added by Netscape and adopted by I.E.

You can find the entire list of 140 color names along with their hexadecimal codes here.

Learning hexadecimal values is not difficult and you’ll soon be able to master gremlins like #CC0099.

Colors for monitors are in expressed in RGB, Red, Green and Blue. The combinations of these colors yield other colors. The RGB values can be expressed in percentages, integer values 0-255 or hexadecimal values 00 – FF.

Since we are concerned about colors on web pages we shall concentrate on hexadecimal representation. In this notation, we use numbers 0 to 9 and alphabet A to F.
0 means no color and F means full color.

Each color in hexadecimal notation takes six digits, where the first two represent RED, the send two, GREEN and the last two BLUE color.

Let us look at some examples.

FF0000 makes red color. Here the intensity of red is highest (denoted by two Fs), while green and blue have zero values (denoted by two 0s for each color).

00FF00 makes green. Values for red and blue are specified at the minimum (two zeros for each red and blue) and green is at its maximum with two Fs.

0000FF makes blue with red and green at zero (two 00s each) and blue at maximum (two Fs).

Get the picture? Here are a few more examples to clear any doubts.

FFFF00 Red and Green in full intensity combine to make Yellow.

FF00FF Red and Blue make Pink.

00FFFF Green and Blue make Cyan.

990000 A dark shade of red. Remember that any digit below F will darken the color and digits above 0 will lighten it.

006600 Deep Green color, almost like olive green.

00CCFF This is a combination of Green (at CC) and Blue (at FF) to produce a lighter shade of blue.

999999 All colors have been expressed in almost half their intensity. This yields gray.

CCCCCC A lighter shade of Grey.

So what do you think will be the codes for Black and White?
White is made using all colors at their highest intensities and is thus, FFFFFF. Black means no color and is represented by minimizing all colors to zero values, 000000.

Using hexadecimal color notation as attribute values

When used as values for attributes, the hexadecimal color code should be prefixed by a # sign. Thus, <BODY BGCOLOR=”#0000FF”> will yield a page with blue background and <FONT COLOR=”#FFFF00″> will set the font color to yellow. You can use these to change the default colors for TEXT, LINK, VLINK, ALINK, BGCOLOR etc.

Experiment with various values till you get a hang of it.

Printers use another color palette called the CMYK, Cyan, Magenta, Yellow and Black (represented by K). As a rule, graphics for monitors should be in RGB and for printing should be in CMYK.