HEX, RGB and HSL: A Practical Guide to Web Colors
HEX, RGB and HSL are three ways to write the same colors. Learn what each one means, when to use it, and how to convert between them instantly for free.
On the web, the same colour can be written three main ways: HEX, RGB and HSL. They all describe the same pixels; they just suit different tasks.
The three formats
- HEX, such as
#0ea5e9, is compact and the most common in CSS and design tools. - RGB, such as
rgb(14,165,233), uses red, green and blue channels and is useful with alpha transparency. - HSL, such as
hsl(199,84%,48%), uses hue, saturation and lightness and is intuitive for tweaking a colour.

Which one should you use?
Use HEX for most CSS and brand colours, RGB when you need transparency, and HSL when you want to create lighter or darker shades by adjusting lightness.
Convert instantly
Rather than converting by hand, paste any colour into the free Color Converter to see it in HEX, RGB and HSL at once, with a live preview.
Tips for accessible colour
- Keep enough contrast between text and background for readability.
- Use HSL to build consistent shade variations of a base colour.
- Document your palette so it stays consistent across pages.