bugl
bugl
HomeLearnPatternsPathsSearch
HomeLearnPatternsPathsSearch

Loading lesson path

Learn/HTML/HTML Foundations
HTML•HTML Foundations

HTML RGB and RGBA Colors

Flash cards

Review the key moves

1/3
Core idea

What is the main idea behind HTML RGB and RGBA Colors?

Lesson checks

Practice each idea before moving on

Short Mimo-style checks built from this lesson's code, terms, and sequence.

1Quick choice

Which statement best captures the main point of this lesson?

2Order

Put the learning moves in the order that makes the concept easiest to apply.

An RGBA color value is an extension of RGB with an Alpha channel (opacity).
An RGB color value represents RED, GREEN, and BLUE light sources.
HTML RGB and RGBA Colors

An RGB color value represents RED, GREEN, and BLUE light sources.

An RGBA color value is an extension of RGB with an Alpha channel (opacity).

RGB Color Values

In HTML, a color can be specified as an RGB value, using this formula:

rgb( red, green , blue )

Each parameter (red, green, and blue) defines the intensity of the color with a value between 0 and 255.

This means that there are 256 x 256 x 256 = 16777216 possible colors!

For example, rgb(255, 0, 0) is displayed as red, because red is set to its highest value (255), and the other two (green and blue) are set to 0.

Another example, rgb(0, 255, 0) is displayed as green, because green is set to its highest value (255), and the other two (red and blue) are set to 0.

To display black, set all color parameters to 0, like this: rgb(0, 0, 0).

To display white, set all color parameters to 255, like this: rgb(255, 255, 255).

Example

Experiment by mixing the RGB values below:

RED

GREEN

BLUE

Shades of Gray

Shades of gray are often defined using equal values for all three parameters:

RGBA Color Values

RGBA color values are an extension of RGB color values with an Alpha channel - which specifies the opacity for a color.

An RGBA color value is specified with:

rgba( red, green , blue, alpha )

The alpha parameter is a number between 0.0 (fully transparent) and 1.0 (not transparent at all):

Example

Experiment by mixing the RGBA values below:

RED

GREEN

BLUE

ALPHA

Previous

HTML Colors

Next

HTML HEX Colors