colorhexrgbhsldesigncss

HEX, RGB, HSL: what is the difference between color formats

Let's look at four color formats: HEX, RGB, HSL and CMYK. When to use each, how to convert, code examples.

Published February 23, 2026·Time to read: 8 min

Color formats on the web

In web development and design, colors are specified in several ways. Each format has its advantages.

HEX (#RRGGBB)

Hexadecimal notation is the most common format on the web.

color: #4f46e5; /* Indigo */ 
color: #09090b; /* Almost black */ 
color: #fff; /* Short form #ffffff */ 

Pros: Brevity, clarity for designers, supported everywhere.

RGB (Red, Green, Blue)

Sets the color through the intensity of three channels from 0 to 255.

color: rgb(79, 70, 229); /* Indigo */ 
color: rgba(79, 70, 229, 0.5); /* With transparency */ 

Pros: Intuitive, convenient for programmatic color manipulation.

HSL (Hue, Saturation, Lightness)

The most “human” format: hue (°), saturation (%), lightness (%).

color: hsl(243, 75%, 59%); /* Indigo */ 
color: hsl(243, 75%, 45%); /* Darker */ 
color: hsl(243, 75%, 75%); /* Lighter */ 

Pros: Easily create tonal palettes by changing only the lightness.

CMYK (Cyan, Magenta, Yellow, Key/Black)

Used in printing.

cmyk(66%, 69%, 0%, 10%) = Indigo 

Pros: Exact color match when printed.

When to use what?

ProblemFormat
------
CSS stylesHEX or HSL
Animations and calculationsHSL or RGB
Printing, brand bookCMYK
Transparencyrgba() or hsla()

Convert colors online with our tool - HEX, RGB, HSL, CMYK and WCAG contrast checker.

We use cookies for analytics. Privacy Policy You can accept or decline non-essential tracking.