Color · #RGB, #RGBA, #RRGGBB, #RRGGBBAA
Hex color
#RRGGBB notation, its shorthand forms and the 8-digit alpha variant.
Key facts
| Forms | #RGB, #RGBA, #RRGGBB, #RRGGBBAA |
|---|---|
| Channels | Red, green, blue, optional alpha |
| Range | 00–ff per channel |
| Color space | sRGB |
| Shorthand rule | Each digit is doubled |
| Case | Case-insensitive |
Shorthand is exact, not rounded
#f0a expands to #ff00aa because each digit is duplicated. That means shorthand can only express colors whose channel bytes have equal nibbles. If a designer writes #f0a intending a specific value, the expanded value is the one that renders.
Eight digits and alpha
CSS Color 4 defines #RRGGBBAA, with alpha as a hex byte rather than a 0–1 float. #ff000080 is red at roughly 50% opacity. Older tools may ignore the last two digits, so test the target renderer when alpha matters.
Frequently asked questions
Is hex RGB or something else?
Hex is sRGB. It is not CMYK and not a device-independent color space.
Why does #fff look the same as #ffffff?
Shorthand doubles each digit, so #fff expands to #ffffff.
Can I use 4-digit hex?
Yes, #RGBA is defined in CSS Color 4, with the last digit as alpha.