Understanding HEX Color Codes in Web Design
A complete guide to how 6-digit hexadecimal numbers translate into Red, Green, and Blue light.
Key Technical Takeaway
HEX color codes are a hexadecimal representation of Red, Green, and Blue byte channels (#RRGGBB). Each pair ranges from 00 (0) to FF (255) in base-16 math.
What is a HEX Color Code?
A hexadecimal color code is a six-character format representing the intensity of Red, Green, and Blue light emitted by digital displays. Formatted as #RRGGBB, each pair of characters is a hexadecimal number ranging from 00 (zero intensity, or 0 in decimal) to FF (maximum intensity, or 255 in decimal).
/* Examples of HEX Color Codes */
#FF0000 -> Pure Red (R: 255, G: 0, B: 0)
#00FF00 -> Pure Green (R: 0, G: 255, B: 0)
#0000FF -> Pure Blue (R: 0, G: 0, B: 255)
#FFFFFF -> Pure White (R: 255, G: 255, B: 255)
#000000 -> Pure Black (R: 0, G: 0, B: 0)How Hexadecimal Counting Works
Instead of base-10 (0-9), hexadecimal uses base-16 (0-9 followed by A-F). A represents 10, B represents 11, up through F which represents 15. The formula to calculate decimal value from a two-digit hex string "XY" is (X * 16) + Y.
- 00 = 0 (No light emitted)
- 80 = 128 (~50% brightness)
- FF = 255 (Full light intensity)
- Shorthand 3-digit hex (#F00) expands by duplicating each character (#FF0000).
- 8-digit hex codes (#RRGGBBAA) add an Alpha channel for opacity (00 = fully transparent, FF = fully opaque).