ColorApr 6, 2026 · Updated Oct 13, 2026 · 2 min read

HTML Color Codes Explained: HEX, RGB, HSL & Beyond

Every CSS color format with examples, current support for wide-gamut color(), and what we found measuring the 148 named colors: only 139 distinct values, and darkgray is brighter than gray.

Concept, abstract, painting — illustrating HTML Color Codes Explained
🔄
Try the Color Converter
Convert between HEX, RGB, HSL, HSB & CMYK instantly — free tool
→
DG
Derek Giordano
Designer & Developer
In this guide
01The Formats at a Glance02Named Colors: Measured03Which Format to Use

The Formats at a Glance

FormatExampleNotes
HEX#FF6B6B, #F66, #FF6B6B803, 4, 6 or 8 digits; the last pair is alpha
rgb()rgb(255 107 107 / 50%)space syntax; rgba() is now an alias
hsl() / hwb()hsl(0 100% 71%)hue-based, easy to edit, not perceptual
lab() / lch() / oklab() / oklch()oklch(0.72 0.17 25)perceptual; can express colors beyond sRGB
color()color(display-p3 1 0.3 0.3)any predefined space, e.g. Display P3 for wide-gamut screens
Namedtomato148 keywords, plus transparent and currentColor

All of these describe the same thing, a color, and convert into each other; how to convert HEX and RGB by hand or in code is covered in our HEX to RGB guide. MDN's compatibility data lists color() in Chrome and Edge 111, Firefox 113 and Safari 15, so wide-gamut values are usable today with an sRGB fallback before them.

Named Colors: Measured

We read the CSS Color 4 keyword table (via the coloraide library) and computed each color's relative luminance, the brightness measure WCAG contrast uses (October 14, 2026; script in our test folder):

Which Format to Use

The Color Converter reads every format above and returns the others, gamut-mapping colors that fall outside sRGB.

Convert any color code instantly

Paste a HEX, RGB, or HSL value and get every format at once. Free, no signup.

⚡ Open Color Converter
DG
Derek Giordano
Written by the creator of Ultimate Design Tools. BA in Business Marketing.