HEX Color Codes Explained: The Complete Guide

Guide Β· Updated 2026-07-28 Β· Yexla Team

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.

FormExampleMeaning
6-digit#1E90FFStandard RRGGBB
3-digit#F00Shorthand β€” each digit doubles (#FF0000)
8-digit#1E90FF80RRGGBBAA β€” last pair is alpha (80 β‰ˆ 50%)
4-digit#F008Shorthand 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.

Frequently asked questions

How many HEX colors are there?

16,777,216 β€” 256 values per channel across three channels (256Β³).

What is the difference between 3-digit and 6-digit HEX?

3-digit HEX is shorthand where each digit is doubled: #F0A expands to #FF00AA. It covers only 4,096 of the 16.7 million colors.

Can HEX codes have transparency?

Yes β€” 8-digit HEX (#RRGGBBAA) adds an alpha pair: 00 fully transparent, FF fully opaque. Supported in all modern browsers.

Is HEX the same as RGB?

Same model, different notation. #FF8800 and rgb(255, 136, 0) are identical colors.