What is a hex color?
A six-digit (or three-digit) hexadecimal representation of a color's red, green, and blue components, the most common way to write colors in CSS and design tools.
Also known as: hex code, hexadecimal color
A hex color like #2563eb encodes three bytes: 25 for red (37/255), 63 for green (99/255), eb for blue (235/255). A leading # is conventional in CSS and design tools. The three-digit shorthand #fff expands to #ffffff; an eight-digit form (#2563ebcc) adds an alpha channel.
Hex is convenient because it is dense (six characters versus rgb(37, 99, 235)) and unambiguous. It is also why most brand styleguides list colors as hex first: it is the format designers paste between Figma, the codebase, and a Slack message without conversion.
The downside is that hex is not perceptually meaningful: you cannot eyeball whether #7c3aed is brighter than #6d28d9 from the digits alone. For programmatic manipulation (deriving hover states, generating shade scales), HSL or OKLCH is much better. The pragmatic flow is: design and store as hex, manipulate as OKLCH, output as hex.
In the wild
#635bffas Stripe's primary brand purple- A CSS variable
--brand: #2563eb;referenced throughout a stylesheet - A design token JSON file mapping
primary.500to#3b82f6