Glossary

Hex color

A hex color is a way of writing an RGB (and optionally alpha) color value as hexadecimal digits, most commonly #RRGGBB — a # followed by six hex digits: two each for red, green, and blue, every pair ranging from 00 to ff (0–255 in decimal). It's the most common color notation in CSS and design tools, standardized as part of the W3C CSS Color specification.

How it works

Each channel pair is a base-16 number from 00 (no intensity) to ff (full intensity, 255 in decimal):

#ff0000  → red   = 255, green = 0,   blue = 0    (pure red)
#00ff00  → red   = 0,   green = 255, blue = 0    (pure green)
#1d1d1f  → red   = 29,  green = 29,  blue = 31    (near-black gray)

CSS also supports a 3-digit shorthand (#f00 expands to #ff0000 by duplicating each digit) and, since CSS Color Module Level 4, an 8-digit form with alpha (#ff0000ff = opaque red, #ff000080 ≈ 50% transparent red) alongside the equivalent 4-digit shorthand.

Common pitfalls

  • The 3-digit shorthand expands by duplicating each digit, not by appending a zero — #abc is #aabbcc, not #ab0c00.
  • Hex notation has no native way to express color outside the sRGB gamut — wide-gamut colors need a different CSS function (color(), lab(), etc.).
  • The alpha channel in 8-digit hex is easy to misread as extra color precision rather than transparency — #ff000080 is still pure red, just half-transparent.
  • Hex is case-insensitive (#FF0000 = #ff0000), but mixed case in a codebase makes diffs noisier for no benefit — pick a convention and stick to it.

Related terms

  • sRGB — the color space that gives hex color's RGB numbers their actual meaning (without it, #ff0000 is just three numbers with no defined appearance).

See also

  • Tool: Color Picker — pick a color visually and copy it as hex, RGB, HSL, or CMYK instantly.