Understanding Color on the Internet

There are several ways in which color is represented on the Internet and in its underlying source code. This article takes a detailed look at the original web safe color palette, Webhex or Html color codes and the Html color naming standard.

The Early Years of the Internet

When the Internet was first released to the public in the 1990s, computers were more primitive than they are today. Back then it was fairly common to have computer systems which only displayed 256 colors on-screen.

In 1993 the Mosaic graphical web browser was released by the National Center for Supercomputing Applications (NCSA). A year later the Netscape Navigator web browser was released. Microsoft would follow in 1995 with the release of their Internet Explorer web browser which was bundled with Windows 95. All of these early browsers shared a color palette known as the web safe color palette which consisted of 216 colors.

The web safe color palette standard allowed web pages to be viewed consistently, in terms of colors, regardless of the web browser you were using. As long as you had a graphics display capable of 256 on-screen colors, you would not experience color dithering unless the web page content itself strayed from this palette.

If you were lucky enough to have a graphics card capable of displaying more than 256 colors (such as 16 or 24 bit color), you were safe from the undesirable effects of color dithering even when straying from the web safe 216 color palette.

The Web Safe Color Palette

The 216 colors for the web safe color palette were decided upon in a way which allows each color component (red, green and blue) to be selected from 6 different intensity levels. Because this arrangement only requires or represents a total of 216 unique colors, there are 40 colors left over on a 256 color display. This enables the computer’s operating system to maintain a consistent color scheme for it’s graphical user interface components.

There are clearly limitations to this color palette. Many designers were not thrilled with it. It does however provide the widest range of possible colors given that there are only 216 colors in total.

The web safe color palette is known by many names, including : The Web-safe palette, The Browser-safe palette, The Mosaic palette, The Netscape palette and the The 216 palette.

With a 256 color display it becomes difficult to represent 16 million colors without introducing dithering or noise. Color dithering is a way to mix pixels of various colors from a limited color palette (such as the 216 color web-safe palette) to provide the illusion of colors that could not otherwise be directly displayed.

Color dithering can be noticeable in photo-realistic images. However, it can be downright difficult to read colored text on colored backgrounds which have been dithered. Large areas of solid colors, when dithered, can become altogether unattractive and messy compared to their originally intended colors.

By sticking to the web-safe colors, designers could be certain that in most cases they could produce pure colors without dithering on all web browsers. There are exceptions of course such as when the computer was only capable of 16 on-screen colors or worse black and white only like the original Macintosh. These systems introduced heavy amounts of dithering in their attempts to display more simultaneous colors than they were natively capable of doing. The results were often ugly.

There are no strong reasons to work with this palette today unless the audience for your web sites are using older computers. Modern computers have no trouble displaying more than enough colors. They also do not require any form of visually noticeable dithering to do so.

In hind-site it might have been nice if the web standards back then would have allowed a web page to define it’s own 216 color palette. Of course this is a moot point now. Today with modern computers we are spoiled in our color options.

Below is a table which displays the web safe 216 color palette. The webhex or html color code (see definition below) is also provided for each color.

000000 000033 000066 000099 0000CC 0000FF
003300 003333 003366 003399 0033CC 0033FF
006600 006633 006666 006699 0066CC 0066FF
009900 009933 009966 009999 0099CC 0099FF
00CC00 00CC33 00CC66 00CC99 00CCCC 00CCFF
00FF00 00FF33 00FF66 00FF99 00FFCC 00FFFF
330000 330033 330066 330099 3300CC 3300FF
333300 333333 333366 333399 3333CC 3333FF
336600 336633 336666 336699 3366CC 3366FF
339900 339933 339966 339999 3399CC 3399FF
33CC00 33CC33 33CC66 33CC99 33CCCC 33CCFF
33FF00 33FF33 33FF66 33FF99 33FFCC 33FFFF
660000 660033 660066 660099 6600CC 6600FF
663300 663333 663366 663399 6633CC 6633FF
666600 666633 666666 666699 6666CC 6666FF
669900 669933 669966 669999 6699CC 6699FF
66CC00 66CC33 66CC66 66CC99 66CCCC 66CCFF
66FF00 66FF33 66FF66 66FF99 66FFCC 66FFFF
990000 990033 990066 990099 9900CC 9900FF
993300 993333 993366 993399 9933CC 9933FF
996600 996633 996666 996699 9966CC 9966FF
999900 999933 999966 999999 9999CC 9999FF
99CC00 99CC33 99CC66 99CC99 99CCCC 99CCFF
99FF00 99FF33 99FF66 99FF99 99FFCC 99FFFF
CC0000 CC0033 CC0066 CC0099 CC00CC CC00FF
CC3300 CC3333 CC3366 CC3399 CC33CC CC33FF
CC6600 CC6633 CC6666 CC6699 CC66CC CC66FF
CC9900 CC9933 CC9966 CC9999 CC99CC CC99FF
CCCC00 CCCC33 CCCC66 CCCC99 CCCCCC CCCCFF
CCFF00 CCFF33 CCFF66 CCFF99 CCFFCC CCFFFF
FF0000 FF0033 FF0066 FF0099 FF00CC FF00FF
FF3300 FF3333 FF3366 FF3399 FF33CC FF33FF
FF6600 FF6633 FF6666 FF6699 FF66CC FF66FF
FF9900 FF9933 FF9966 FF9999 FF99CC FF99FF
FFCC00 FFCC33 FFCC66 FFCC99 FFCCCC FFCCFF
FFFF00 FFFF33 FFFF66 FFFF99 FFFFCC FFFFFF

Webhex or Html color codes

Webhex is simply a hexadecimal representation of a 24 bit color. Webhex colors are also known as Html color codes.

Refer to our previous article entitled An introduction to Bits, bytes and Hexadecimal for more help on understanding some the the concepts that we will be delving into next.

Webhex consists of a hexadecimal triplet. That is to say it is built up from three separate hexadecimal values, each of which represents the red, green and blue component of a color.

In 24 bit color, each of these components are described with a single byte. This means that each of the red, green and blue color components are defined with 8 bits each (8 x 3 = 24 bits) which allows for 256 unique values. This enables you to support red, green a blue decimal values from 0 to 255.

As an example, a bright purple with a maximum amount of red and blue but with no green intensity at all could be defined like so :

Red 255 | Green 0 | Blue 255

This color is known as Coder’s Pink. It has been used historically by programmer’s to represent the background or transparent color of graphical objects (also known as Sprites) in video games.

Next we will need to convert the decimal values into their hexadecimal equivalents. One decimal byte (which in itself can contain one to three decimal digits) converts to one or two hexadecimal digits. If the result is only a single digit we must precede it with a zero so that we always have two hexadecimal digits representing one byte. The end results is that a webhex value contains a total of 6 hexadecimal digits.

Converting the decimal values of the color above (255, 0 and 255) into their Hexadecimal equivalents (and adding a zero to the beginning of our single hexadecimal green value) we arrive at the following :

Red FF | Green 00 | Blue FF

Again, it is important that the single zero is padded with another zero in order to make two hexadecimal digits. In total we now have 6 hexadecimal digits and can bring these together into the form that web hex is usually presented in. Notice the number sign (#) preeceding the end result which simply indicates that the value which follows is hexadecimal rather than simply a decimal value.

#FF00FF

If it wasn’t for the preceding number sign, the value could be mistaken for a decimal value. The hexadecimal value of #123456 is quite different from the decimal value of 123456.

The table below shows how a hexadecimal pair is made. The first digit is the number of 16s in the color value, and the second digit is the number of ones. The decimal equivalents are also detailed for your reference.

Color value x 16 Decimal Color value x 1 Decimal
F 240 F 15
E 224 E 14
D 208 D 13
C 192 C 12
B 176 B 11
A 160 A 10
9 144 9 9
8 128 8 8
7 112 7 7
6 96 6 6
5 80 5 5
4 64 4 4
3 48 3 3
2 32 2 2
1 16 1 1
0 0 0 0

Converting Decimal Bytes into Hexadecimal

If we wanted to convert a decimal value of 173 into hexadecimal we could use the table above to help us. First we would find the closest value on the left (number of 16s) without exceeding our value of 173. This happens to be 160 which gives us our first hexadecimal digit of A.

Next we would then subtract the 160 from our 173 which results in a remainder of 13. From the table above we can see that 13 in decimal is the same as D in hexadecimal. Bring these hexadecimal values together and we find that :

173 (decimal) = AD (hexadecimal)

Performing this process on all three color components allows us to build up a complete web hex or html color code that was originally based on decimal byte values. Just remember to pad any single digit hexadecimal results with a zero and precede the end result with a number sign.

12 Bit Color Web Hex

Although not supported by all applications, 12 bit RGB Web Hex is an alternative for describing a color by using 4 bits per color component. As 4 bits can represent 16 unique values, this means that we are able to use 16 different intensities of red, green and blue. This allows us to define our color from a color gamut of exactly 4,096 colors.

12 bit color was used by several older computers like the Amiga and the Atari STE, and video game consoles of the past.

A 12 bit web hex color is comprised of only 3 hexadecimal digits in total. The pink color that we defined earlier (see above) would translate to :

#F0F

This is a shorter way to define colors, requiring only half the number of characters as compared to 24 bit webhex. If you are just getting started with webhex (or hexadecimal numerals in general) it might be easier and faster to work with 12 bit webhex at first before you move on to 24 bit webhex.

12 bit webhex is useful for a few different reasons. First, it’s easier to work with. Second, it requires less characters to define a color. Finally, sometimes a color really only needs 12 bits to be described. In other words (as with our demonstration color above) we are not loosing any information in the color’s components when we convert it to and from 24 bit color.

In the table for 24 bit webhex (above) you will see that the left-hand hexadecimal digit supports values up to 240 (decimal). With 12 bit Web Hex it is assumed that the right-hand digit is the same as the left-hand digit. The table below takes this into consideration and allows you to find the closest match between a 12 bit webhex value and it’s decimal equivalent.

Hex Decimal
FF 255
EE 238
DD 221
CC 204
BB 187
AA 170
99 153
88 136
77 119
66 111
55 102
44 85
33 51
22 34
11 17
00 0

If you do not mind loosing a little accuracy with your colors (in some cases), you could convert them to 12 bit webhex easily by using the table above. As an example let’s take the following 24 bit color (described in decimal RGB) and convert it into the closest 12 bit webhex equivalent :

Red 234 | Green 117 | Blue 78

Simply find the closest match in the table above for each color component byte value. We only need to keep the first hexadecimal digit. The converted value becomes :

#D74

As you can see, 12 bit webhex certainly does make things easier. Of course you sacrifice the ability to display some colors in the process. Your particular application of webhex will help you determine if the convenience of 12 bit webhex doesn’t interfere with the color accuracy that you require.

Html Color Names

The Mosaic and Netscape Navigator web browsers both started out as Unix X Window applications. They simply borrowed the X11 color names which would later be standardized as the official Html color names.

There are 147 colors in total and these can be referred to by name rather then defining colors using webhex. The Html color names are supported by most web browsers.

It may appear that there are some duplicate colors below. However, colors which have Gray in the names are repeated with the alternate spelling of Grey.

Color Name WEB HEX Color
AliceBlue #F0F8FF  
AntiqueWhite #FAEBD7  
Aqua #00FFFF  
Aquamarine #7FFFD4  
Azure #F0FFFF  
Beige #F5F5DC  
Bisque #FFE4C4  
Black #000000  
BlanchedAlmond #FFEBCD  
Blue #0000FF  
BlueViolet #8A2BE2  
Brown #A52A2A  
BurlyWood #DEB887  
CadetBlue #5F9EA0  
Chartreuse #7FFF00  
Chocolate #D2691E  
Coral #FF7F50  
CornflowerBlue #6495ED  
Cornsilk #FFF8DC  
Crimson #DC143C  
Cyan #00FFFF  
DarkBlue #00008B  
DarkCyan #008B8B  
DarkGoldenRod #B8860B  
DarkGray #A9A9A9  
DarkGrey #A9A9A9  
DarkGreen #006400  
DarkKhaki #BDB76B  
DarkMagenta #8B008B  
DarkOliveGreen #556B2F  
Darkorange #FF8C00  
DarkOrchid #9932CC  
DarkRed #8B0000  
DarkSalmon #E9967A  
DarkSeaGreen #8FBC8F  
DarkSlateBlue #483D8B  
DarkSlateGray #2F4F4F  
DarkSlateGrey #2F4F4F  
DarkTurquoise #00CED1  
DarkViolet #9400D3  
DeepPink #FF1493  
DeepSkyBlue #00BFFF  
DimGray #696969  
DimGrey #696969  
DodgerBlue #1E90FF  
FireBrick #B22222  
FloralWhite #FFFAF0  
ForestGreen #228B22  
Fuchsia #FF00FF  
Gainsboro #DCDCDC  
GhostWhite #F8F8FF  
Gold #FFD700  
GoldenRod #DAA520  
Gray #808080  
Grey #808080  
Green #008000  
GreenYellow #ADFF2F  
HoneyDew #F0FFF0  
HotPink #FF69B4  
IndianRed #CD5C5C  
Indigo #4B0082  
Ivory #FFFFF0  
Khaki #F0E68C  
Lavender #E6E6FA  
LavenderBlush #FFF0F5  
LawnGreen #7CFC00  
LemonChiffon #FFFACD  
LightBlue #ADD8E6  
LightCoral #F08080  
LightCyan #E0FFFF  
LightGoldenRodYellow #FAFAD2  
LightGray #D3D3D3  
LightGrey #D3D3D3  
LightGreen #90EE90  
LightPink #FFB6C1  
LightSalmon #FFA07A  
LightSeaGreen #20B2AA  
LightSkyBlue #87CEFA  
LightSlateGray #778899  
LightSlateGrey #778899  
LightSteelBlue #B0C4DE  
LightYellow #FFFFE0  
Lime #00FF00  
LimeGreen #32CD32  
Linen #FAF0E6  
Magenta #FF00FF  
Maroon #800000  
MediumAquaMarine #66CDAA  
MediumBlue #0000CD  
MediumOrchid #BA55D3  
MediumPurple #9370D8  
MediumSeaGreen #3CB371  
MediumSlateBlue #7B68EE  
MediumSpringGreen #00FA9A  
MediumTurquoise #48D1CC  
MediumVioletRed #C71585  
MidnightBlue #191970  
MintCream #F5FFFA  
MistyRose #FFE4E1  
Moccasin #FFE4B5  
NavajoWhite #FFDEAD  
Navy #000080  
OldLace #FDF5E6  
Olive #808000  
OliveDrab #6B8E23  
Orange #FFA500  
OrangeRed #FF4500  
Orchid #DA70D6  
PaleGoldenRod #EEE8AA  
PaleGreen #98FB98  
PaleTurquoise #AFEEEE  
PaleVioletRed #D87093  
PapayaWhip #FFEFD5  
PeachPuff #FFDAB9  
Peru #CD853F  
Pink #FFC0CB  
Plum #DDA0DD  
PowderBlue #B0E0E6  
Purple #800080  
Red #FF0000  
RosyBrown #BC8F8F  
RoyalBlue #4169E1  
SaddleBrown #8B4513  
Salmon #FA8072  
SandyBrown #F4A460  
SeaGreen #2E8B57  
SeaShell #FFF5EE  
Sienna #A0522D  
Silver #C0C0C0  
SkyBlue #87CEEB  
SlateBlue #6A5ACD  
SlateGray #708090  
SlateGrey #708090  
Snow #FFFAFA  
SpringGreen #00FF7F  
SteelBlue #4682B4  
Tan #D2B48C  
Teal #008080  
Thistle #D8BFD8  
Tomato #FF6347  
Turquoise #40E0D0  
Violet #EE82EE  
Wheat #F5DEB3  
White #FFFFFF  
WhiteSmoke #F5F5F5  
Yellow #FFFF00  
YellowGreen #9ACD32  

Conclusion

We have learned a little bit of history in regards to the use of color on the Internet. As well we have looked at three different ways of describing colors : 24 bit webhex, 12 bit webhex and Html color names. Below is a quick example which demonstrates these various ways of describing color.

color = #F8B136
color = #A7F
color = Thistle

Comments

  1. Johanna Fiebelkorn says:

    Very interesting information!Perfect just what I was looking for!

Speak Your Mind

*

Read previous post:
Associative Arrays in PHP

PHP supports a plethora of data types and associative arrays are a very convenient way to represent data collections that...

Close