Color · Red, green, blue
RGB color
Three sRGB channels from 0 to 255, plus optional alpha.
Key facts
| Channels | Red, green, blue |
|---|---|
| Integer range | 0–255 |
| Percentage range | 0%–100% |
| Alpha | 0–1 in CSS |
| Modern syntax | rgb(255 0 0 / 50%) |
| Color space | sRGB unless stated |
Two syntaxes
Legacy CSS uses commas: rgb(255, 0, 0) and rgba(255, 0, 0, 0.5). Modern CSS uses spaces and a slash for alpha: rgb(255 0 0 / 0.5). Both describe the same color and both are supported in current browsers.
Not every RGB is sRGB
rgb() in CSS refers to sRGB. A camera raw file or a profiling tool may use a different RGB space with different primaries. Copying channel numbers between spaces changes the color even though the numbers match.
Frequently asked questions
Why is 255 the maximum?
Each channel is stored as one byte, and 255 is the largest value a byte can hold.
Is rgba() still needed?
No. <code>rgb()</code> accepts alpha with the slash syntax; <code>rgba()</code> remains for compatibility.
How do I convert RGB to hex?
Write each channel as two hex digits and concatenate: 255, 0, 128 becomes #ff0080.