Look at these three lines of CSS: #2563EB, rgb(37, 99, 235), and hsl(221, 83%, 53%). On screen, all three paint the exact same royal blue pixel. None of them has a wider color range or better browser performance. The real difference is human readability and maintainability.

1. RGB: Direct Hardware Control

RGB stands for Red, Green, Blue, with each channel ranging from 0 (completely off) to 255 (maximum brightness). It mirrors how screen hardware works and is easy to read when troubleshooting brightness:

2. HEX: Compact Shorthand for RGB

A HEX code is simply an RGB value compressed into base-16 (hexadecimal) notation using digits 0–9 and letters A–F. The six characters split cleanly into three pairs: #RRGGBB.

Each pair calculates as (first digit × 16) + second digit:

Pro tip on shorthand & alpha: When every pair repeats (like #FF8800), CSS lets you shorten it to 3 digits (#F80). You can also add two extra digits at the end for opacity—for example, #2563EB80 sets 50% transparency.

3. HSL: Built for Human Intuition

Try looking at #2563EB and mentally making it 12% darker for a button hover state—it is nearly impossible without opening a picker. That is why designers and front-end engineers love HSL (Hue, Saturation, Lightness):

Side-by-Side Examples

Color HEX RGB HSL
Coral #FF7F50 rgb(255, 127, 80) hsl(16, 100%, 66%)
Royal Blue #2563EB rgb(37, 99, 235) hsl(221, 83%, 53%)
Sea Green #2E8B57 rgb(46, 139, 87) hsl(146, 50%, 36%)
Rebecca Purple #663399 rgb(102, 51, 153) hsl(270, 50%, 40%)

Building a Cohesive UI Scale With HSL

One of the cleanest CSS tricks is storing your brand's Hue and Saturation once, then shifting only Lightness to generate an entire palette of backgrounds, borders, buttons, and hover states that never clash:

Which Format Should You Pick?

🎛️ Try the Interactive RGB / HEX / HSL Mixer → Next Guide: Mixing Clean Paint Without Mud →