Understanding Color Formats: HEX, RGB, HSL & More

HEX, RGB, HSL, and more: understanding different color representations for web development.

basicsformatsdesign

Color Formats Explained

Different color formats serve different purposes. Here's what each offers.

HEX Colors

Hexadecimal representation of RGB values.

#RRGGBB or #RGB (shorthand)
#FF5733 = RGB(255, 87, 51)
#F00 = #FF0000 = RGB(255, 0, 0)

With alpha:
#FF573380 = 50% transparent

Best for: CSS, design tools, quick notation

RGB / RGBA

Red, Green, Blue values (0-255).

rgb(255, 87, 51)
rgba(255, 87, 51, 0.5) / 50% transparent /

/ Modern syntax /
rgb(255 87 51)
rgb(255 87 51 / 50%)

Best for: Programmatic color manipulation

HSL / HSLA

Hue, Saturation, Lightness - more intuitive!

hsl(14, 100%, 60%)
hsla(14, 100%, 60%, 0.5)

/ Hue: 0-360 (color wheel position)
Saturation: 0-100% (gray to vivid)
Lightness: 0-100% (black to white)
/

Best for: Creating color variations, themes

HSL Color Wheel

0° = Red
60° = Yellow
120° = Green
180° = Cyan
240° = Blue
300° = Magenta
360° = Red (wraps around)

Modern: OKLCH

Perceptually uniform color space (CSS Color Level 4).

oklch(70% 0.15 180)
/ Lightness, Chroma, Hue /
Best for: Accessible color palettes, consistent perceived brightness

Frequently Asked Questions

Common questions about this topic

HEX (#FF5733) for solid colors - it's compact and widely understood. RGB/RGBA when you need transparency or programmatic manipulation. HSL when creating color schemes (easy to adjust lightness/saturation). Modern browsers support all formats equally.

HSL separates hue (the actual color) from saturation and lightness. To create lighter/darker versions, just change L. To create muted versions, reduce S. In RGB, creating variations requires changing all three values in non-intuitive ways.

sRGB is a specific RGB color space - the standard for web and most displays. 'RGB' can refer to any RGB color space (Adobe RGB, Display P3). CSS colors are sRGB by default. CSS Color Level 4 adds support for wider gamuts with color() function.