Part 3: Using Hexadecimal to Express Color

All colors are mixtures of the three primary colors: red, green, and blue. A hexadecimal color code uses a six digit number. The first two digits are the value for red, the next two for green, and the last two for blue. This is called the RGB (Red, Green, Blue) color model.


Hex Code "808080"= Red 80, Green 80, Blue 80


This is a mixture of equal amounts of the three colors. The result is a medium gray.

Each value uses two hexadecimal digits, giving you 256 possibilities for each color. Since there are three colors, the total number of possible colors is 256 X 256 X 256 = over 16 million.


If all values are set to 0, the screen will be black:

Hex Code: 00 00 00


If they are set to the maximum (hex FF, decimal 255), the screen will be white.

Hex Code: FF FF FF


The screen is gray when all three colors are at the same value, somewhere between minimum (black) and maximum (white).

Dark Gray
Hex Code: 20 20 20

Medium Gray
Hex Code: 50 50 50

Light Gray
Hex Code: B0 B0 B0

Primary colors

To produce pure colors, leave two colors at 0, and set a value for the third color (the desired color).

Hex Code: FF 00 00

Hex Code: 00 FF 00

Hex Code: 00 00 FF

Mixing Colors

Set values for two or three of the colors to obtain colors that are a mixture of the primary colors.


Mixing colors in HTML is directly opposite from mixing colors with paint. Low amounts of color make dark shade; high amounts of color make bright shades. With HTML, you are mixing light, not paint.

Hex Code: F0 F0 00
(Red + Green)

Hex Code: 60 00 60
(Dark Red + Dark Blue)

Hex Code: FF 70 00
(Red + Medium Green)

Hex Code: 90 50 30
(Red, Green, and a little Blue)

Use the automatic color mixer to experiment.

Continue on to the Quiz

Back to Table of Contents

© Copyright 1997 Los Trancos Systems, LLC. Used with permission. All rights reserved.