Back to Updates
DevTool Team

CSS Color Notation: The Differences Between HEX, RGB, HSL, and HSV

Why does CSS have several ways to write the same color? This guide explains the design intent behind HEX, RGB, and HSL — hex is compact, rgb is channel-native, hsl matches how humans adjust color — plus where HSV fits: a color model used by every design tool, yet never a CSS syntax. Includes the alpha notations (rgba/8-digit hex) and an online converter.

Why one color has three spellings

Open any CSS file and the same blue may appear three ways: #3d84fd, rgb(61, 132, 253), hsl(218, 98%, 62%). They all point to the identical color — the three notations are not three color systems but three coordinate systems over the same color space, each designed for a different job.

HEX: the compact, machine-friendly spelling

The hexadecimal color #RRGGBB is a compact encoding of the three RGB channels: two hex digits per 0-255 channel. In #3d84fd, 3d=61, 84=132, fd=253.

Its virtues are brevity and stability — six characters (three in shorthand), the lingua franca between design software and CSS, copy-paste lossless. The cost is human readability: you can't tell whether 61 is dark or light, let alone that #3d84fd is "a fairly bright blue".

Transparency extends it to eight digits, #RRGGBBAA (e.g. #3d84fd80), with the AA byte mapping to a 0-1 decimal via round(a×255).

RGB: thinking in channels

rgb(61, 132, 253) exposes the intensity of the three light channels. It is the most direct model of how screens mix color — three sets of sub-pixels — so when you want "a slightly brighter blue" you reach for the third number… until you hit 253 and realize the ceiling. That is RGB's weakness: channel values don't correspond to color perception. Eyes are most sensitive to green and least to blue, so raising all three channels equally does not brighten uniformly.

RGB's home turf: programming interfaces (Canvas/WebGL pixel data is all RGB), LED control, anywhere you operate channel by channel.

HSL: designed for human color intuition

hsl(218, 98%, 62%) decomposes color the way people talk about it: hue (which color family, 0-360° around the wheel), saturation (how vivid), lightness (how bright).

It is the only notation whose parameters map to intuitive operations:

  • Darken a button hover state: drop l by 8% — with HEX/RGB you'd need to know which channel to touch and by how much
  • Generate a family of accents from one hue: lock h, step s/l — a design-system staple
  • Match a danger color's brightness to the brand color: just equalize l

CSS treats HSL as a first-class citizen (the hsl()/hsla() functions, Color 4 space syntax, calc() support), making it a regular in theme systems and CSS variables.

HSV: not a CSS syntax, but the star of design tools

The fourth regular needs a clarification: HSV is a color-science model, not a CSS notation — CSS has never standardized hsv(). Yet in Photoshop, Figma, and nearly every color picker, the panel's slider logic is HSV.

The crucial difference from HSL is the third parameter:

  • HSV's V (Value): the absolute value of the brightest channel — pure colors have V=100%
  • HSL's L (Lightness): the midpoint of the brightest and darkest — pure colors have L=50%

The consequences: the same color has different numbers (hsv(0,100%,100%) vs hsl(0,100%,50%) for pure red), and the gradients along the axis behave differently — HSV's top row runs from gray to pure (handy for pickers), while HSL puts pure colors at the middle and white at the top. Design apps love HSV; CSS chose HSL.

Transparency: notations for the fourth channel

Alpha has three mainstream, equivalent notations:

Notation Example Notes
rgba()/hsla() fourth parameter rgba(61,132,253,0.5) 0-1 decimal, the classic
8-digit hex #3d84fd80 AA=round(0.5×255)=128
Color 4 space syntax rgb(61 132 253 / 0.5) modern; rgb() takes alpha too

Watch the quantization: the AA byte is a 0-255 integer, so 0.5 alpha maps to 128 rather than an exact half (255/2=127.5) — round trips carry 1/255 granularity.

In practice: which to choose, and how to convert

Rules of thumb:

  1. Design handoff and everyday CSS: HEX (short, universal)
  2. Color tuning and theme systems: HSL (parameters match intuition)
  3. Pixel-level programming: RGB (native to the interfaces)
  4. Design-software color panels: understand they run on HSV — don't mistake V for L

For converting among the four formats (alpha included), use the color converter: edit any format and the rest sync instantly, with a native picker, checkerboard alpha preview, and one-click normalized copy — hex to rgb, rgb to hex, and hsl/hsv conversion in one place.

Frequently Asked Questions

Are hex and rgb just two spellings of the same color?

Yes. #3d84fd and rgb(61,132,253) point to the exact same color — hex is simply the compact hexadecimal spelling of the three RGB channels (3d=61, 84=132, fd=253), with zero information difference. Which one you use is purely situational: hex is shorter in CSS and is the lingua franca of design-software color fields; rgb's decimal numbers are easier to reason about when you need to tweak one channel.

When should HSL be used instead of HEX/RGB?

Whenever you think in hue/saturation/lightness: darkening a button hover state (drop l by 10%), generating a family of accents with one hue (fix h, vary s/l), or matching the lightness of a danger color to the brand color — HSL's parameters map directly to those operations, while HEX/RGB require conversion tools. Modern CSS also lets hsl() participate in calc(), increasingly common in theme systems.

Why is HSV not a CSS color notation?

HSV (HSB) is a color-science model — the hue/saturation/value cylinder used by virtually every design app's color picker (Photoshop and Figma panels run on HSV logic) — but CSS has never standardized an hsv() function; CSS chose HSL. The key difference is the third parameter: HSV's V is the absolute value of the brightest channel, while HSL's L is the midpoint of the brightest and darkest. A pure color has V=100% in HSV but L=50% in HSL.

What are the notations for transparency?

Three mainstream, fully interchangeable forms: the fourth parameter of rgba()/hsla() (a 0-1 decimal); the 8-digit hexadecimal #RRGGBBAA (the AA byte is 0-255, e.g. #3d84fd80 is about 50%); and the CSS Color 4 space syntax rgb(61 132 253 / 0.5). Note the quantization: the AA byte is an integer, so 0.5 alpha maps to 128 (round(0.5×255)), and round trips carry 1/255 granularity.