Understanding HEX Color Codes
A HEX color code is a 6-character hexadecimal string that represents a color. The format is #RRGGBB — two characters for red, two for green, two for blue. Each pair is a base-16 number from 00 to FF, which corresponds to decimal 0–255.
Reading a HEX code
Take #FF0000 (pure red). The pairs are FF (red), 00 (green), 00 (blue). FF in hex is 255 in decimal, so this is rgb(255, 0, 0). #FFFFFF has FF in all three channels — that's rgb(255, 255, 255), pure white. #000000 has 00 everywhere — black.
3-digit shorthand
When each pair has identical characters, HEX can be shortened to 3 digits. #F00 = #FF0000 = red. #FFF = #FFFFFF = white. #000 = #000000 = black. The shorthand works because each character is doubled when expanded.
Common hex codes
| Color | Hex | RGB |
|---|---|---|
| White | #FFFFFF | rgb(255, 255, 255) |
| Black | #000000 | rgb(0, 0, 0) |
| Red | #FF0000 | rgb(255, 0, 0) |
| Green | #008000 | rgb(0, 128, 0) |
| Blue | #0000FF | rgb(0, 0, 255) |
| Yellow | #FFFF00 | rgb(255, 255, 0) |
HEX vs RGB vs HSL
HEX and RGB describe the same color differently. HEX is compact; RGB is more explicit. HSL (Hue, Saturation, Lightness) organizes colors by perceived hue and is often easier to adjust visually. See our RGB vs HEX vs HSL guide.
Related tools
FAQ
What is a 6-digit hex code?
Two hex digits for each of red, green, and blue channels, prefixed by #.
Can HEX have alpha?
Yes — 8-digit HEX adds two digits for alpha (transparency), e.g. #FF000080.
Is HEX case-sensitive?
No. #ff0000 and #FF0000 are the same color.