In CSS, a color can be defined using an RGB value, employing the formula:
rgb(red, green, blue)
Each parameter (red, green, and blue) determines the intensity of the color within a range of 0 to 255.
For instance, rgb(255, 0, 0) represents red because red is maximized at 255 while green and blue are set to 0.
To render black, all color parameters should be set to 0, as in: rgb(0, 0, 0).
To render white, all color parameters should be set to 255, as in: rgb(255, 255, 255).
Explore various color combinations by adjusting the RGB values below:
Example
Shades of gray are typically described by having equal intensities across all three light sources.
Example
RGBA color values expand upon RGB color values by incorporating an additional alpha channel, determining the opacity level for a color.
An RGBA color value is defined as:
rgba(red, green, blue, alpha)
The alpha parameter ranges from 0.0 (fully transparent) to 1.0 (completely opaque):
Explore various combinations of RGBA values to observe their effects.
Example