rgb()

The rgb() function defines a color from red, green, and blue channels plus an optional alpha.

Since CSS1 Spec ↗

Syntax

rgb(R G B / A)

Examples

.a { color: rgb(37 99 235); }
.b { background: rgb(0 0 0 / 0.06); }
.c { color: rgb(255 255 255 / 80%); }
Output
Renders solid blue text, a 6% black tint background, and 80% opaque white text.

Notes

Modern space-separated syntax with a slash for alpha is preferred over the legacy comma form. Channels accept 0 to 255 or percentages. For perceptually uniform palettes prefer oklch().

Browser & runtime support

EnvironmentSince version
chrome 1.0
firefox 1.0
safari 1.0
edge 12

See also