|Everyone who wants to introduce color in their e-mail or signature and webpages soon comes to learn that there are two ways to do so: either by naming a color or by specifying a HEX CODE. Easy enough to go to a link such as the one just given, look at the colors and choose to use one specification or the other. To understand, though, how the HEX codes for colors are differently distinguished is helpful, for the actual full range of colors that can be represented by HEX codes is not realizable nor practical.|
| Colors in HTML may be given by a six digit HEX code of the form ######.
Each pair of digits, ##, may be said to represent gradations in the three primary colors red, green, and blue (RGB). Choosing a pair of digits for each of these primary colors in a HEX code can be viewed as "mixing" RGB gradations to give another particular color.|
Non-dithering colors are colors that do not change from what was originally intended upon being viewed from different browsers. These practical HEX codes consist of only 3 pairs of digits for each of the primary colors:
|This is very convenient, at least for organizational purposes, since it means that any 2 pairs of HEX codes can have all possible arrangements given by a table:|
|This is a 6x6 table, so there are 36 cells in this table. To introduce the 3rd set, place the HEX pair of digits, 00, before the 2 HEX pairs in each cell and there is obtained a table for all colors whose HEX code begins with 00. Do the same for 33, 66, and so on and there is obtained 6 tables of HEX codes for all 216 non-dithering colors. These are given below:|
|These 6 color tables represent slices made through a color cube. If one was able to view this as if the cube was transparent the entire kaleidascope of non-dithering colors would be seen on the faces and throughout the cube.|
It is instructive and informative to now view each pair of HEX codes for a color as representing a particular value for R, G and B, as in the RGB representation of colors. Here the 256 possible shades of R, G, and B are each assigned a number from 0 to 255. Using the color cube values, though, only 6 shades of R, G, and B are considered.
How these are to be used is readily illustrated by generating the shades of gray between white, ffffff, and black, 000000. It will be noted that equal values of R, G and B must pertain. There is thus obtained:
|If all 16 HEX codes were used in this way there would be a steady progression of shadings going from black to white.|
The darker primary color shades for RGB are obtained by "blacking-out",i.e,setting as 00, the other primary colors. The lighter shades are gained by "whiting-out", i.e.setting as ff, the chosen primary and combining the other two.
|Here too use of all 16 HEX codes would lead to a progression of the primary colors going from their darkest to their lightest shade. This progression is plainly seen using other sets of HEX codes, as shown below.|
|Any two primary colors can be "mixed" or combined in just as consistant a progression by "blacking-out", i.e., setting as 00, the third. And as before, the lighter shades are gained by "whiting-out", setting as ff, the primary colors that are combined. Again, all 16 HEX codes could have been used for this illustration.|
|Even at this early stage it is evident that the color cube describes not so much color, there being only 6 differing colors, but shades of these colors. It is also plain that all 16 of the HEX code pairs can be used for them and their shadings. The choice of only 6 pairs of HEX codes is no more and no less than an expedient. There is nothing "magical" to the non-dithering nature of these 6 pairs, all 16 pairs meet the same criteria. They designate the intensity for the R, G and B color beams of a TV or monitor. Dithering will take place if these beams are out of balance, a common occurence. Otherwise they are non-dithering.|
Continuing the "mixing" of color pairs provides alternative shade groupings. Less than 6 HEX codes are used when an abrupt color change takes place, designating a cross-over to another color domain.
|This section may be difficult for some as it does entail a mathematical construct. Continue if desired, but otherwise return to the more general information.|
A BIT is a switch that can be either 0 or 1, i.e., it has 2 different settings. Many systems use BYTEs consisting of 4 bits. So 4 bits can represent 2 x 2 x 2 x 2 or 16 different bytes.
Control & Character Equivalents
With 2 bytes independent of one another 16 x 16 different things can be represented, e.g., keyboard characters, typewriter operations such as space or return, or cursor/screen commands such as cursor home or scroll. Making a checkerboard-like table 16 items across (a row, r) and 16 items down (a column, c), each "thing" can be identified by rc, its HEX CODE according to which row and which column it may be in. Labeling the 16 items across and down by 0 to 1 AND a to f gives hex codes as are usually seen, e.g., 76, 0d, or ea. These are often used as a type of machine language.
Numbering the cells in a sequential manner gives an ASCII sequence table which identifies all characters and typewriter operations possible on a typewriter keyboard, including those characters obtained using special keys like "cmd" and "alt". Additional symbols and characters are to be found in an extended ASCII table or a table for ctrl or alt sequences. All of these have HTML codes known as HTML-equivalents.
Consider the Red, Green, Blue (RGB) representation of color. Each of these is given a number from 0 to 255 going from when the color "looks" blackest to when it "looks" whitest. Mixing RGB gives any visible color desired, just as with a color TV set. So there are actually 256x256x256 (some millions) of possible colors and shadings of color.
Why the number 256? It has to do with bits (on-off switches) and bytes (collections of these). For a set of 4 bits there are 16 ways of having on-off for them. With 2 sets of 4 there are 16x16 ways (bytes), i.e., 256 ways. All possibilities can be represented as a table with rows and columns labeled:
0 1 2 3 4 5 6 7 8 9 a b c d e f
There are 16 of these, so it is termed a HEXadecimal representation.
To identify any one cell just give the HEXadecimal value corresponding to the row and column it is in, e.g., 4f, a5, 88, or bb. The RGB system just labels the cells sequentially for R, G, and, B, i.e., 1 for 00 , 2 for 02, going to 256 for ff.
The 216 base colors often referred to applies ONLY to those RGB HEX codes for which the HEX representation is every 3rd one and the same, i.e., 00, 33, 66, 99, cc and ff. That is only 6 pairs. Three tables of hex codes for are needed for RGB, so taking only these HEX representation, to specify a color three PAIRS of hexadecimal values are needed; for example 00 cc aa, which is what is usually done in HTML.
All possible combinations of ONLY these HEX code colors can be made by creating a table of, say, G and B combinations for which the rows and columns would be labeled:
00 33 66 99 cc ff
There are here 6x6 or 36 such cells. Putting the 1st HEX value for R in every cell of this, then the 2d, and so on gives 6x36 or 216 possible colors. In a 3-D (x,y,z-axis) representation this would be a cube, so it is called the 216 color-cube. It is also a selection of "non-dithering" colors, i.e., the color selected will show up the same independent of the type of browser and will not be viewed a different color than intended. This is the basis for Beth's background color chart. These can also be specified by a name rather than a hexcode.
What about the other colors?? These are the ones most often found named. Their hex code PAIRS for RGB are the same,e.g., 2f 66 3d.
Even if this explanation is not entirely understood by the viewer perhaps an idea has been gained of why things with most computers are just 16s or multiples thereof, e.g., 16 or 32 bit processors or 256 base HEX character equivalents.