๐ŸŽจ HEX, RGB, and HSL: Three Ways to See Color

Understanding color formats every frontend developer should know

Three Formats at a Glance

FormatExampleMeaningBest For
HEX#3b82f6RGB in hexadecimalCSS, design handoff
RGBrgb(59,130,246)Red, Green, Blue (0-255 each)JavaScript, Canvas
HSLhsl(217,91%,60%)Hue (0-360ยฐ) + Saturation + LightnessTheme systems, accessibility
Key insight: HEX is just RGB in base-16. HSL is a human-friendly perspective on the same color โ€” easier to adjust and reason about.

When to Use Each Format

HSL's Superpower: Effortless Color Variations

Want a darker hover state? Drop L from 60% to 50%. Lighter variant? Raise L to 80%. With RGB you'd have to guess three numbers.

/* HSL theme palette in one line */
--primary:       hsl(217, 91%, 60%);  /* main */
--primary-light: hsl(217, 91%, 80%);  /* lighter */
--primary-dark:  hsl(217, 91%, 40%);  /* darker */

Modern CSS Color Formats

๐Ÿ‘‰ Convert colors now

HEX โ†” RGB โ†” HSL real-time, color picker, one-click copy

๐ŸŽจ Open Color Converter

FAQ

Q: Are #3b82f6 and rgb(59,130,246) the same?

Yes. HEX is base-16: 3b=59, 82=130, f6=246. Same color, different notation.

Q: When should I use HSL over HEX?

When you need to programmatically generate color variants (themes, gradients, hover states). HSL makes "lighter/darker/saturated" trivial.

๐Ÿ“– Related: Regex Tester โ†’ ยท JSON Formatter โ†’