CSS: rgb()
RGB function using integers, with opacity
RGB color by integer, 0 to 255
Syntax, with space separator
/* 3 integers, separated by space */ p { background-color: rgb(255 215 0); } /* percentage */ p { background-color: rgb(100% 84% 0%); }
Opacity (optional)
/* color with opacity */ /* a decimal value between 0 and 1 */ p { background-color: rgb(255 215 0 / 0.5); } /* can also be a percentage */ p { background-color: rgb(255 215 0 / 50%); }
Syntax, with comma separator (legacy)
/* comma as separator */ p { background-color: rgb(255, 215, 0); } /* percentage */ p { background-color: rgb(100%, 84%, 0%); }
rgba function (legacy)
- there was a legacy function
rgba. rgbais for rgb with opacity (“a” for “alpha channel”), separate fromrgbfunction.- today as of 2026-05-12, they are merged.
rgbais an alias torgbfunction.
when is css rgba legacy function.
- Officially since CSS Color Module Level 4 (the current standard).
- Browsers started supporting the modern syntax around 2018–2019.
- By 2022–2023, the spec and the community started clearly calling the old rgba() syntax legacy.
rgba(red, green, blue, opacity)
- red green blue each can either be a integer from
0to255, or a percentage from0%to100%. - opacity should be from 0 to 1.
p.x { background-color: rgba(255, 215, 0, 0.5); } p.y { background-color: rgba(100%, 84%, 0%, 50%); }
CSS Color
- CSS: color syntax. Index
- CSS: Color Names
- CSS: RGB Color
- CSS: rgb()
- CSS: HSL Color
- CSS: HWB color (hue whiteness blackness)
- CSS: what is Wide Color Gamut, Display P3, sRGB.
- CSS: LAB, LCH color
- CSS: OKLCH color
- CSS: color() function
- CSS: color-mix() function
- CSS: Opacity (Transparency)
- JS: Convert Color Names to RGB, and to HSL