Web Design

How Hex Color Codes Work

From #000000 to #FFFFFF — everything you need to know about hex colors on the web.

Published: May 7, 2026 · 7 min read

The Anatomy of a Hex Color Code

A hex color code is a six-digit hexadecimal number preceded by a hash symbol (#). The six digits are divided into three pairs, each representing one color channel: Red, Green, and Blue (RGB). The format is #RRGGBB.

Each pair ranges from 00 (0 — no color) to FF (255 — full intensity). For example:

#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 — White (all channels at maximum)
#000000 — Black (all channels at zero)

How to Read RGB from Hex

Take the color #FF5733:

Red: FF = 255 (full red)
Green: 57 = 87 (moderate green)
Blue: 33 = 51 (low blue)

This produces a vibrant orange-red color. Each hex pair is simply converted from base 16 to base 10 to get the RGB value (0–255).

Shorthand Hex Codes

When each of the three pairs has matching digits, CSS allows a three-digit shorthand:

#FF0000#F00
#00FF00#0F0
#336699#369

The browser expands each digit by duplicating it. So #F00 becomes #FF0000.

8-Digit Hex Codes (with Alpha)

Modern CSS also supports 8-digit hex codes in the format #RRGGBBAA, where the last two digits represent opacity (alpha channel). 00 is fully transparent and FF is fully opaque.

For example, #FF573380 gives the same orange-red with roughly 50% transparency.

Common Color Hex Values

Here are frequently used hex colors every web developer should know:

#FFFFFF — White
#000000 — Black
#808080 — Gray
#FF0000 — Red
#00FF00 — Lime Green
#0000FF — Blue
#FFFF00 — Yellow
#FF00FF — Magenta
#00FFFF — Cyan

Try Our Color Tools

Convert between hex and RGB instantly with our free tools:

Hex to RGB Converter — Enter a hex code, get the RGB values
RGB to Hex Converter — Enter RGB values, get the hex code