#0f6b5c, rgb(15, 107, 92) and hsl(170, 75%, 24%) look like three different colors, but they are the same deep teal written three ways. Designers, developers and brand guides switch between these formats all the time, and knowing how they relate makes it much easier to pick colors, adjust them and keep them consistent. This guide explains each format in plain terms.
How screens make color
Every pixel on a screen is made of three tiny lights: red, green and blue. By mixing different brightnesses of those three, a screen can show millions of colors. All red, all green and all blue at full brightness make white; all three off make black; equal amounts of each make a shade of grey. HEX and RGB both describe a color directly as those three brightness levels, while HSL describes the same color in a way that’s closer to how people think about it.
RGB: three numbers from 0 to 255
RGB lists the brightness of red, green and blue as numbers from 0 (off) to 255 (full brightness). Some examples:
rgb(255, 0, 0)is pure red.rgb(255, 255, 0)is yellow: red and green light together make yellow on a screen.rgb(128, 128, 128)is a medium grey.rgb(15, 107, 92)is a deep teal: a little red, a moderate amount of green and slightly less blue.
Why 255? Each channel is stored in one byte, eight bits, which holds 256 values (0 to 255). Three channels give 256 × 256 × 256, about 16.7 million possible colors.
HEX: the same numbers in base 16
A HEX code is just RGB written in hexadecimal, a counting system with 16 digits (0–9 then a–f). Each pair of characters is one channel: #RRGGBB.
Take #0f6b5c:
0fin hexadecimal is 0 × 16 + 15 = 15 (red)6bis 6 × 16 + 11 = 107 (green)5cis 5 × 16 + 12 = 92 (blue)
So #0f6b5c is exactly rgb(15, 107, 92). Three-character shorthand doubles each digit: #0f9 means #00ff99. An optional fourth pair adds transparency: #0f6b5c80 is the same teal at about 50% opacity. HEX codes are popular because they’re short and easy to copy, which is why brand guidelines usually list them.
HSL: hue, saturation and lightness
HSL describes a color with three properties people naturally use:
- Hue is the position on a color wheel, from 0 to 360 degrees: 0 is red, 120 is green, 240 is blue, and everything in between is a blend.
- Saturation is how vivid the color is, from 0% (grey) to 100% (as intense as possible).
- Lightness runs from 0% (black) through 50% (the pure color) to 100% (white).
Our teal, hsl(170, 75%, 24%), has a hue between green (120) and cyan (180), fairly strong saturation, and low lightness, which makes it deep and dark.
The big advantage of HSL is that it makes adjustments predictable. To get a lighter version of a color, raise the lightness; for a muted version, lower the saturation; for a matching color with a different hue, rotate the hue. Doing the same with RGB numbers involves changing all three values at once in ways that are hard to judge by eye.
Converting between formats
HEX and RGB convert exactly, since they’re the same numbers in different notation. HSL is calculated from RGB with a short formula, and HSL values are usually rounded to whole numbers, so converting RGB → HSL → RGB can shift a channel by a step or two. The difference is invisible, but it means you should keep one format, usually HEX, as the “official” value in your brand guide. The color converter shows all three formats side by side and lets you copy whichever you need.
Building tints and shades with HSL
Here’s a practical way to build a small palette from one brand color. Keep the hue and saturation, and step the lightness:
| Use | HSL | HEX |
|---|---|---|
| Very light background | hsl(170, 75%, 94%) | #e4fbf7 |
| Light accent | hsl(170, 75%, 70%) | #79ecd9 |
| Brand color | hsl(170, 75%, 24%) | #0f6b5c |
| Dark text on light backgrounds | hsl(170, 75%, 14%) | #093e36 |
Because every step shares the same hue, the palette looks consistent. Many designers also reduce the saturation slightly for the very light and very dark steps so they don’t look neon or muddy.
Making sure text is readable
Color choices affect whether people can read your content, including the many people with low vision or color blindness. The Web Content Accessibility Guidelines (WCAG) define a contrast ratio between text and its background, from 1:1 (identical colors) to 21:1 (black on white).
- Level AA (the common legal and policy standard) requires 4.5:1 for normal text and 3:1 for large text.
- Level AAA requires 7:1 for normal text and 4.5:1 for large text.
Lightness is the main thing that drives contrast, which is another reason HSL is handy: if white text on your brand color fails the check, lower the lightness a few points and test again. The converter calculates the ratio for white and black text instantly.
Which format should you use?
- Writing a brand guide or handing colors to a designer: HEX, plus RGB for completeness.
- Writing CSS: whichever your team prefers; HSL makes hover states and themes easier to reason about.
- Adding transparency:
rgb(15 107 92 / 50%)orhsl(170 75% 24% / 50%)reads more clearly than an eight-digit HEX code. - Printing: none of these. Print uses CMYK inks or Pantone spot colors, which cover a different range of colors. Ask your printer to match a screen color, and expect small differences.
Once you see that all three formats are the same red, green and blue light described in different ways, moving between them stops feeling like a chore, and HSL becomes one of the most useful tools you have for creating colors that work together.