HEX Color Codes Explained: The Complete Guide
A HEX color code is a six-digit hexadecimal number that tells a screen exactly how much red, green and blue light to emit. #6C5CE7 means red 6C (108), green 5C (92), blue E7 (231) β a violet. HEX is the lingua franca of web color: compact, unambiguous and supported everywhere since the earliest browsers.
How to read a HEX code
The format is #RRGGBB. Each pair is a base-16 number from 00 (0) to FF (255). Because 16Γ16 = 256 values per channel, HEX encodes 256Β³ = 16,777,216 colors β identical to RGB, just written differently. Reading tips: high first pair = lots of red; equal pairs = gray; #FF0000 pure red, #00FF00 pure green, #0000FF pure blue, #FFFFFF white, #000000 black.
| Form | Example | Meaning |
|---|---|---|
| 6-digit | #1E90FF | Standard RRGGBB |
| 3-digit | #F00 | Shorthand β each digit doubles (#FF0000) |
| 8-digit | #1E90FF80 | RRGGBBAA β last pair is alpha (80 β 50%) |
| 4-digit | #F008 | Shorthand with alpha |
Converting HEX
To convert HEX to RGB by hand, translate each pair from base 16: multiply the first digit by 16 and add the second (A=10 β¦ F=15). In practice, use our HEX to RGB converter β or go straight to HSL, CMYK or modern OKLCH.
When HEX is the wrong tool
HEX values are hard to reason about β you cannot easily make a HEX color "20% lighter". For systematic manipulation use HSL or, better, OKLCH, which keeps perceived lightness consistent across hues. HEX also cannot express wide-gamut Display P3 colors.