Capt. Horatio T.P. Webb
About Color -- RGB, Alpha and Color Picker
Parks -- Spring 2014

Version 7 -- Last Updated 9:00 PM 5/11/2014

COLOR PART I: RGB | 24-bit color | truecolor | 3 byte color

A single pixel's color is based on 3 numbers that represent: (1) the amount of red; (2) the amount of green; and (3) the amount of blue that are combined to produce a single color. Each of the three colors has 256 possible intensities (0 → 255) yielding 256 x 256 x 256 or 16,777,216 possible colors.

Below is a 3D oblique projection of a color grid representation of the "truecolor" or "24-bit" color model. There are 3 dimensions: red (0→255); green (0→255); blue (0→255) that create a 256 x 256 x 256 pixel 3D cube (16,777,216 unique colors). When the slider for the "chosen color" is moved (chosen by the radio buttons at the bottom right), one of the 256 planes of of the "chosen color" is shown where ALL the pixels in the "chosen color" plane have the slider value. There are 65,536 different values for the non-chosen colors (256 x 256) in each visible plane.

 Pick a Constant Color Plane to show:

Your Browser Doesn't support canvas

HTML 4 color components were specified with four basic formats:
  1. rgb(a number 0→255 for red intensity,a number 0→255 for green intensity,a number 0→255 for blue intensity)


    • rgb(0,0,0) is black (the darkest gray)
    • rgb(127,127,127) is medium gray
    • rgb(255,255,255) is white (the brightest gray)
    • rgb(255,0,0) is the brightest red
    • rgb(0,255,0) is brightest green
    • rgb(0,0,255) is brightest blue

  2. rgb(a percent 0→100 for red intensity,a percent 0→100 for green intensity,a percent 0→100 for blue intensity)


    • rgb(0%,0%,0%) is black (the darkest gray)
    • rgb(50%,50%,50%) is medium gray
    • rgb(100%,100%,100%) is white (the brightest gray)
    • rgb(100%,0,0) is the brightest red
    • rgb(0,100%,0) is brightest green
    • rgb(0,0,100%) is brightest blue

  3. #rrggbb where:
    • rr is a two digit hexademinal number 00→ff (0-255 in decimal) for red intensity
    • gg is a two digit hexademinal number 00→ff (0-255 in decimal) for green intensity
    • bb is a two digit hexademinal number 00→ff (0-255 in decimal) for blue intensity


    • #000000 is black (the darkest gray)
    • #777777 is medium gray
    • #ffffff is white (the brightest gray)
    • #ff0000 is the brightest red
    • #00ff00 is brightest green
    • #0000ff is brightest blue

  4. by color name

    There are 147 named colors in HTML. See:

    • "Black" is black (the darkest gray)
    • "LightGray" or "LightGrey" is light gray
    • "White" is white (the brightest gray)
    • "Red" is the brightest red
    • "Lime" is brightest green
    • "Blue" is brightest blue
COLOR PART II: RGB Alpha | 32-bit color | 4 byte color

Textbox to receive the picked color from below:

HTML5 adds a fourth color component called variously: "alpha", "opacity", or "transparency", This is expressed as the fourth number in the "red,green,blue,alpha" or "rgba" string. The values for "alpha" range from 0.0 → 1.0. Specifically:

The reason this is called "alpha" is not because it is more simple than saying "opacity" or "transparency" (which both mean the same thing -- just from a different directions), but because the generic term is from "alpha channel". This terminology is most often used in graphic image editors to describe the transparency layer of an image. This information references to how the red, green and blue color information should be merged with the color that is "underneath" or "behind" the image.

See these transparency/opacity examples in HTML5's canvas.

Thus, when working with transparencies/opacity there is a need to be able to refer to how the color (the one on top) and the background (the one underneath) are merged or composited together.

The "color-alpha picker" above allows the user to pick the blue, red, green and alpha values and provide the color-alpha specification in a textbox.

HTML 5 specifies a new input type named "color" that appears like a textbox. When the user clicks in the textbox a color picker is shown that allows the user to pick the rgba colors by sight and then place the rgba color specification in the textbox.

The w3c spec (as of 5/2013) is here.

Chrome 33 and Opera 18 (April 2014) bring up a rgb color picker when the user clicks in the textbox with a default color of black. Other browsers tested did nothing. The color pickers that worked are rgb ONLY -- they do NOT allow for alpha to be chosen as the W3C input type=color specification states:

"The input element represents a color well control, for setting the element's value to a string representing a simple color."

Above "a simple color" means a hexadecimal rgb color -- like red: "#ff0000". It is curious that since HTML 5 has many rgba color possibilities that the spec doesn't discuss or suggest anything about 24-bit color with opacity/transparency.

See how to use the rgb-alpha color picker as <input type=color... as an iframe here

There are 16,777,216 (256 x 256 x 256) possible combinations of:

Combined with the alpha channel, we get an addition choice of 101 possible values for transparency → opacity. This color picker expresses as alpha as 0.00 → 1.00 yielding 101 opacity possible choices (16.777 million x 101 or 1,694,498,816 possible rgba color values).

Without alpha (i.e., red and green and blue only in 3 bytes) color is commonly called "true color" or "24-bit color" or "3 byte color". With alpha, it is 32-bit or 4-byte color. Even though we are only using 101 values (0.00 to 1.00 in 0.01 increments and NOT 0 → 255) the transparency/opacity is stored in the 4th byte -- thus using 32-bits or 4-byte color.