HEX vs RGB
Side-by-side comparison, when-to-use-each guide, and instant conversion. Reviewed for 2026.
CSS authoring (shorter), design tools (Figma, Adobe), social media bios.
CSS when you need alpha (rgba), JavaScript canvas, programmatic colour manipulation.
| Aspect | HEX | RGB |
|---|---|---|
| Pure red | #FF0000 | rgb(255, 0, 0) |
| White | #FFFFFF | rgb(255, 255, 255) |
| With transparency | #FF0000CC (8-digit hex) | rgba(255, 0, 0, 0.8) |
| Character count | 7 (#RRGGBB) | 13+ (rgb(r,g,b)) |
| Browser support | Universal | Universal |
Frequently asked
Can I use 3-character HEX like #F00?
Yes — 3-character HEX is shorthand for 6-character: #F00 = #FF0000. Each digit gets doubled. It only works for colours where each channel uses the same hex digit doubled (so #F50 ≠ #FF5500 in 3-character syntax, but you can write it as the 6-char #FF5500).
What's the difference between RGB and HSL?
RGB sets colour by amount of red, green, blue light. HSL (hue, saturation, lightness) describes colour by where it sits on the colour wheel and how vivid/dark it is. HSL is often easier for designers to think with.
Frequently asked questions
Can I use 3-character HEX like #F00?
Yes — 3-character HEX is shorthand for 6-character: #F00 = #FF0000. Each digit gets doubled. It only works for colours where each channel uses the same hex digit doubled (so #F50 ≠ #FF5500 in 3-character syntax, but you can write it as the 6-char #FF5500).
What's the difference between RGB and HSL?
RGB sets colour by amount of red, green, blue light. HSL (hue, saturation, lightness) describes colour by where it sits on the colour wheel and how vivid/dark it is. HSL is often easier for designers to think with.