Core answer: HEX #RRGGBB is just RGB in hexadecimal: #FF8000 = rgb(255, 128, 0). Convert channel by channel: hex→decimal (FF=255, 80=128, 00=0), or decimal→hex (128 = 8×16+0 = 80). HSL remaps the same color to hue (0–360°), saturation, lightness — designers tweak HSL, developers write HEX, and #FF0000 = rgb(255,0,0) = hsl(0°, 100%, 50%) are the exact same red.

HEX ↔ RGB in 10 seconds

Hex digits: 0–9 then A=10, B=11, C=12, D=13, E=14, F=15. Two-digit hex value = first×16 + second.

HEXMathDecimal
FF15×16+15255
808×16+0128
A310×16+3163
0D0×16+1313

Shorthand: #F80 expands to #FF8800 (each digit doubles). Alpha channel: #FF8000CC adds CC = 80% opacity.

HSL: the human-friendly dial

  • Hue (0–360°): 0 red, 60 yellow, 120 green, 180 cyan, 240 blue, 300 magenta.
  • Saturation: 0% = gray, 100% = vivid.
  • Lightness: 0% black, 50% pure color, 100% white.

Design systems love HSL because "same color, lighter" = same H and S, raise L — no hex math. A hover state is often just L −8%.

Worked examples

Example 1 — Brand color to CSS. Brand guide says PMS-approximate rgb(16, 185, 129): 16 = 10, 185 = B9, 129 = 81 → #10B981 — yes, that's the emerald on this very site.

Example 2 — Reading a screenshot. Color picker grabs #3B82F6: 3B = 59, 82 = 130, F6 = 246 → rgb(59, 130, 246), a sky blue; HSL ≈ hsl(217°, 91%, 60%).

Example 3 — Making a palette. Primary hsl(160°, 84%, 39%): hover = same H/S, L 32%; muted background = S 30%, L 96%; disabled = S 10%, L 60%. One hue, whole system.

Example 4 — 8-digit alpha. 50% black overlay = #00000080 (80 hex = 128 ≈ 50%); 25% white = #FFFFFF40.

Common mistakes and myths

  1. Confusing #FFF vs #FFFFFF — they're identical (shorthand doubles each digit); #F0F is #FF00FF magenta, not a light gray.
  2. HSL 50% lightness ≠ perceived brightness — yellow at 50% L looks far brighter than blue at 50% L; for perceptual work use OKLCH/HSLuv.
  3. Screen vs print — RGB (light, additive) can't express CMYK (ink, subtractive) gamuts fully; that neon green will dull in print. Convert via the printer's ICC profile, not naive formulas.
  4. Assuming hex is color-managed — #FF0000 differs between sRGB and Display-P3 screens; wide-gamut devices need color(srgb …) or oklch() in modern CSS.
  5. Alpha compositing surprises — 50% black over white gives #808080, but over red gives #800000 — semi-transparent overlays shift hue, so test on real backgrounds.