Key takeaways
- A hex code is three pairs of digits: red, green and blue.
- Each pair runs from 00 to FF, which gives 16,777,216 colors.
- Three-digit shorthand works when each pair repeats a digit.
A hex color code is a six-digit value, written after a hash sign, that tells a screen how much red, green and blue to mix. It is the most common way to write colors in CSS, design tools and brand guidelines.
How to read one
Split the code into three pairs. The first pair is red, the second is green and the third is blue. Each pair runs from 00 (none) to FF (full). So #FF0000 is full red with no green or blue, and #0000FF is pure blue.
Why hexadecimal?
Hexadecimal counts in base 16, using the digits 0 to 9 and the letters A to F. Two hex digits can show 256 values, which matches the 256 levels a screen uses for each color channel. That gives 16,777,216 possible colors.
Shorthand codes
When each pair repeats a digit, you can shorten the code. #FFF means #FFFFFF (white) and #000 means #000000 (black).
Want to see the values for any code? Try the color converter.