HEX vs RGB vs HSL
HEX, RGB and HSL are three notations for the same colours in the same gamut, sRGB. HEX packs the red, green and blue channels into compact hexadecimal; RGB states those additive amounts directly; HSL rewrites them as hue, saturation and lightness, the way humans reason. The colour never changes, only which edit is easiest.
Die folgende Anleitung ist nur auf Englisch verfügbar.
HEX vs RGB vs HSL explained
Every colour on a web page ends its journey as three numbers: how much red, green and blue light to emit. The formats differ only in how those numbers are written and grouped. #FF6600, rgb(255, 102, 0) and hsl(24, 100%, 50%) are the same orange, convertible losslessly in both directions, because they all address the same sRGB channels.
HEX won copy-paste culture: design tools, palette sites and style guides hand around six-character strings that identify a colour like a serial number. RGB is the native language of screens and image data. HSL is the newest of the three in CSS and the most opinionated about why you are reaching for a colour — rotating a hue, damping a saturation, building a scale. None is more correct; each makes a different edit cheap.
This guide walks each notation, the alpha variants, the modern CSS color() function, and the accessibility check that outranks every aesthetic choice. Every tool linked along the way runs entirely in your browser.
The fastest way to believe the three notations are one thing is to watch a value flip between them: paste a colour into the Color Converter and every format updates at once — HEX, RGB, HSL and the perceptual options included.
After any palette decision, run the foreground and background pair through the Contrast Checker which reports the exact WCAG ratio and whether it passes at each level — before users with weaker screens find out for you.
One gamut, three notations
sRGB is the default colour space of the web: the spectrum a typical display shows, defined so that every browser, from a phone to a calibrated studio monitor, means the same colour by the same numbers. Each channel runs 0 to 255, which is why 16,777,216 colours (256 cubed) used to be quoted as the size of the web palette. A notation is just a user interface for those three numbers — and for alpha, a fourth number that controls opacity.
Because all three notations resolve to the same channels, conversion between them is exact arithmetic, never approximation. A tool that reports #FF6600 as hsl(24, 100%, 50%) is not offering an opinion; it is doing the same algebra the CSS spec defines. That is also why the format you write has zero effect on rendering — it is purely about the human editing the line.
| Format | Written as | Alpha variant | Easiest when you are |
|---|---|---|---|
| HEX | #FF6600 or #F60 | #FF6600AA (8 digits) | Copying a value verbatim between tools |
| RGB | rgb(255, 102, 0) | rgba(255, 102, 0, 0.67) | Thinking in channel light amounts |
| HSL | hsl(24, 100%, 50%) | hsl(24 100% 50% / 0.67) | Rotating hue or building tints and shades |
| color() | color(srgb 1 0.4 0) | color(srgb 1 0.4 0 / 0.67) | Naming a space explicitly, beyond sRGB |
HEX: compact, portable, opaque
A six-digit HEX code is three bytes in hexadecimal: FF is 255, 66 is 102, 00 is zero. The form dates to the earliest HTML and survives because it is unbeatable as an identifier — short, unambiguous, quote-free. If the two digits of each channel match (FF, 66, 00), CSS also accepts three digits: #F60. Since CSS Color 4, appending two more digits adds alpha: #FF6600AA is the same orange at about 67% opacity.
HEX's weakness is composition. Look at #FF6600 and ask what it will look like 15% darker, or what its complement is, and the answer requires decoding hexadecimal in your head. Darkening #FF6600 by eye produced a generation of #E65C00 guesses. HEX is the format for storing a colour, not the format for reasoning about one — which is exactly the gap HSL was invented to fill.
RGB: the additive model, stated plainly
Screens do not reflect paint; they emit light, and RGB is additive: black is all channels off, white is all on, and every colour is a mixture. rgb(255, 102, 0) says it plainly — full red, some green, no blue. This is the notation that matches the physics, which makes it the natural choice when you are debugging a rendered value, reading image data, or blending light itself (add two RGB colours and you get a brighter result, the opposite of mixing paint).
Its alpha form, rgba(), predates the 8-digit HEX variant. CSS Color 4 also modernised the syntax: rgb(255 102 0 / 0.67) — spaces and a slash instead of commas — is equivalent, and the a is now optional since rgb() accepts four values. Browsers have supported both spellings since around 2023.
HSL: the human-legible wheel
HSL rewrites the same channels as hue (an angle on the colour wheel, 0 to 360: red at 0, green at 120, blue at 240), saturation (0% is grey, 100% is fully vivid) and lightness (0% black, 100% white). Its superpower is legible relationships. Need a hover state 10% lighter? hsl(24, 100%, 50%) becomes hsl(24, 100%, 60%) — one number moved, the intent visible in the diff. Need a five-step brand scale? Hold hue and saturation, vary lightness. In HEX, every one of those edits is a recalculation.
The honest caveat: HSL's lightness is not perceptual. hsl(60, 100%, 50%) (yellow) and hsl(240, 100%, 50%) (blue) both claim 50% lightness, yet the yellow blazes while the blue reads nearly black. Scales built on HSL lightness therefore look uneven to the eye. CSS Color 4 added oklch() to fix exactly this — a cylindrical notation whose lightness matches human perception, so equal steps look equal. For even scales, oklch is the modern answer; this site's colour tools compute ramps in OKLab, the perceptual space behind it.
| Hue | Angle | Common associations |
|---|---|---|
| Red | 0° | Alerts, errors, appetite |
| Yellow | 60° | Warnings, energy |
| Green | 120° | Success, safety, growth |
| Cyan | 180° | Information, calm |
| Blue | 240° | Trust, links, focus |
| Magenta | 300° | Accents, creativity |
Alpha and the modern color() function
Every notation above carries alpha the same way: as a 0-to-1 fraction of opacity. The spellings differ — #RRGGBBAA puts it in hexadecimal (AA is 170, about two-thirds opaque), rgba() and hsla() take a comma-separated fraction, and the modern space-separated syntax writes it after a slash. All produce identical results; the 8-digit HEX form is simply the most compact and the one design tools export most.
color() is the bigger shift. It names the colour space explicitly — color(srgb r g b) is the familiar gamut spelled out, while color(display-p3 ...) addresses the wider gamut of modern screens, and color(oklch ...) exposes the perceptual model. sRGB remains the safe default — content authored in it renders predictably everywhere — while display-p3 colours land only where the syntax is supported, essentially all evergreen browsers since 2023.
- #RRGGBBAA — alpha in hex, AA = 170 ≈ 67% opacity.
- rgba(255, 102, 0, 0.67) — legacy comma syntax, still universal.
- rgb(255 102 0 / 0.67) — CSS Color 4 syntax; the a is optional now.
- color(display-p3 1 0.4 0 / 0.67) — wider-gamut colour, space named up front.
Contrast: the check that outranks taste
No notation choice matters if users cannot read the text. WCAG contrast requires a ratio of at least 4.5:1 between text and its background for normal text at AA level, 3:1 for large text (roughly 24 px regular or 19 px bold and above), and 7:1 for the stricter AAA level. The ratio is computed from relative luminance, which is a property of the colour itself — the notation you wrote it in is irrelevant, which is one more way all these formats are the same colour.
The practical workflow is mechanical: pick colours however you like, then verify pairs before shipping. Body copy over its background, placeholder text over inputs, white text over the brand colour — each pair needs its number. A contrast checker reports it instantly — cheaper than retrofitting an inaccessible palette under deadline.
Frequently asked questions
Do the colour tools on this site upload what I paste?
No. Conversion, picking and contrast checks all run as JavaScript in your browser tab — there is no upload step. Confirm it in DevTools: open the Network panel, convert something, and watch the request list stay empty. The site's Content-Security-Policy also forbids page scripts from making outbound connections.
Do HEX and RGB ever produce different colours?
Never, when both describe sRGB. #FF6600 and rgb(255, 102, 0) are byte-for-byte the same three channel values, and the conversion between the notations is defined arithmetic. Differences only appear when a colour space is named explicitly — color(display-p3 ...) can reach colours sRGB cannot represent, which is a property of the space, not the notation.
Which format should I use in my CSS?
Use HEX for values that are stored and copied as identifiers — brand tokens, design-system variables. Use HSL when the value will be derived: hover states, tints, shades, themes that rotate hue. RGB suits image-adjacent work and anywhere channel amounts are the mental model. Consistency inside a codebase beats any single right answer.
What is #RRGGBBAA and when should I use it?
An eight-digit HEX code where the last two digits are alpha: 00 fully transparent, FF fully opaque, AA about 67%. It is the compact equivalent of rgba(255, 102, 0, 0.67) and is supported everywhere the older rgba() is. Reach for it when a design tool hands you eight digits.
Is HSL lightness the same as how bright a colour looks?
No, and this is the trap that bites palette builders. HSL lightness is a mathematical remapping of the RGB channels, not a perceptual one: yellow and blue at the same 50% lightness look wildly different in brightness. For scales that look even, use oklch() from CSS Color 4, whose lightness tracks human perception — or a tool whose ramps are computed in a perceptual space, as this site's are.
What contrast ratio do I need for accessibility?
WCAG AA requires 4.5:1 for normal text and 3:1 for large text (about 24 px regular or 19 px bold and up); AAA raises these to 7:1 and 4.5:1. The ratio comes from relative luminance, so the notation is irrelevant. Check every text-background pair, including placeholders and disabled states.
Which related tools should I use next?
- Color ConverterConvert between HEX, RGB, HSL, HSV, OKLCH and CMYK, in both directions at once.Open
- Color PickerPick a colour and read it back as HEX, RGB, HSL, OKLCH or CMYK, with a tint and shade ramp.Open
- Contrast CheckerCheck a text and background pair against WCAG 2.2 AA and AAA, and get the nearest colour that passes.Open
- Color ToolsPick, convert, check contrast and test for colour blindness.Open
- PNG vs JPG vs WebP vs AVIFPlain-English guideOpen
- Image ToolsCompress, resize and convert images in the browser.Open