Short answer
RGB stands for Red, Green, Blue. It is the additive color model used by screens. Three light sources are mixed at different intensities to produce every visible color. Each channel is typically written as an integer from 0 to 255, giving a total of 16,777,216 possible colors.

How the three channels work

Every pixel on a screen contains three tiny subpixels: one red, one green, one blue. By controlling the brightness of each independently, the screen can produce any color within its gamut.

Red

rgb(255, 0, 0) · R channel at full, others at zero.

Green

rgb(0, 255, 0) · G channel at full, others at zero.

Blue

rgb(0, 0, 255) · B channel at full, others at zero.

Combining the three in equal amounts produces neutral grays. All three at zero gives black; all three at 255 gives white:

Black

rgb(0, 0, 0)

Mid gray

rgb(128, 128, 128)

White

rgb(255, 255, 255)

Why 0–255?

The range 0–255 comes from using one 8-bit byte per channel. 28 = 256 possible values (0 through 255). One byte per channel keeps image files compact and computation fast. The full color space therefore contains 256 × 256 × 256 = 16,777,216 colors — usually described as "16.7 million colors".

Modern CSS also accepts other units:

SyntaxRangeExample
rgb() with integers0–255rgb(79, 70, 229)
rgb() with percentages0%–100%rgb(31% 27% 90%)
rgb() modern (space-separated)0–255 or %rgb(79 70 229)
Alpha via slash0–1rgb(79 70 229 / 0.5)

Additive color mixing

RGB is additive: adding light makes things brighter. Red and green light together produce yellow — not a darker color as you might expect from paint. Green and blue produce cyan; blue and red produce magenta. All three at full intensity produce white.

Red
Green
Red + Green = Yellow
Green + Blue = Cyan
Blue + Red = Magenta
All three = White

RGB vs HEX

HEX is simply a more compact way to write RGB. Each channel value between 0 and 255 is written as two hexadecimal digits (base 16). Three pairs form a six-digit HEX code.

rgb(79, 70, 229)
  │   │    │
  4F  46   E5    ← each value in hexadecimal (base 16)
  └───┴────┴────→  #4F46E5

The two representations describe the same color. HEX is shorter and easier to paste into code; RGB is more readable and easier to compute with.

RGB vs sRGB vs Display-P3

RGB is the general model. sRGB and Display-P3 are specific color spaces that define exactly how RGB values map to real colors.

SpaceRangeTypical use
sRGBStandard gamutDefault for the web, most screens
Display-P3~25% wider than sRGBModern phones, laptops, wide-gamut displays
Adobe RGBWider than sRGB, different axesPhotography, print preparation
Rec. 2020Much widerHDR, television standards

When you write rgb(255, 0, 0) in CSS, browsers interpret it as sRGB by default. To specify a color in a different RGB space, use the color() function: color(display-p3 1 0 0).

Practical syntaxes

CSS
/* Classic comma syntax */
color: rgb(79, 70, 229);
color: rgba(79, 70, 229, 0.5);

/* Modern space-separated syntax */
color: rgb(79 70 229);
color: rgb(79 70 229 / 0.5);

/* Percentages */
color: rgb(31% 27% 90%);

/* Wide-gamut */
color: color(display-p3 0.30 0.28 0.90);

Continue reading

Frequently asked questions

What is RGB?

RGB stands for Red, Green, Blue. It is the additive color model used by screens: red, green and blue light are mixed at different intensities to produce every visible color. Each channel is typically expressed as a value from 0 to 255.

Why does RGB use values from 0 to 255?

Because 255 is the maximum value that fits in a single 8-bit byte. Using one byte per channel keeps image files compact and computation fast. Modern CSS also supports percentages and floating-point values between 0 and 1, but 0–255 remains the most common convention.

What is the difference between RGB and RGBA?

RGBA adds an alpha channel to RGB. The alpha value controls transparency, from 0 (fully transparent) to 1 (fully opaque). RGB alone cannot represent transparency.

Is RGB the same as sRGB?

Not exactly. RGB describes the general model of mixing red, green and blue. sRGB is a specific, standardized color space that defines exactly how those values map to actual colors. When you write rgb(255, 0, 0) in CSS, it is interpreted as sRGB by default.

What is the difference between additive and subtractive color?

Additive (RGB) means colors are made by emitting light — adding more light makes things brighter. Subtractive (CMYK) means colors are made by absorbing light — adding more pigment makes things darker. Screens use additive; printers use subtractive.