HEX, RGB and HSL Colours Explained (with Quick Conversion Examples)
Designers and developers describe the same colour in different formats. Knowing how HEX, RGB and HSL relate lets you pick, adjust and reuse colours without guessing.
The three formats
| Format | Looks like | How it works |
|---|---|---|
| HEX | #8b5cf6 | Three pairs of hexadecimal digits for red, green and blue |
| RGB | rgb(217, 164, 65) | Red, green and blue, each from 0 to 255 |
| HSL | hsl(39, 67%, 55%) | Hue (0 to 360 degrees), saturation (%), lightness (%) |
All three above describe the same golden colour.
HEX to RGB
Split the HEX into pairs and convert each pair from base 16 to base 10. For #8b5cf6: D9 = 13 × 16 + 9 = 217, A4 = 10 × 16 + 4 = 164, 41 = 4 × 16 + 1 = 65. So the RGB value is (217, 164, 65).
Why HSL is handy
- Hue is the colour on the wheel: 0 is red, 120 green, 240 blue.
- Saturation is how vivid it is: 0% is grey, 100% is full colour.
- Lightness is how bright it is: 0% is black, 100% is white.
To make a darker button, keep hue and saturation and lower lightness. This is much easier than editing RGB numbers.
Check contrast for readability
Text must stand out from its background. The WCAG accessibility guidelines suggest a contrast ratio of at least 4.5 : 1 for normal text and 3 : 1 for large text. Light grey text on white, or gold on a bright background, often fails. Dark text on a light colour, or light text on a dark colour, usually passes.
Practical tips
- Choose one brand colour, then create lighter and darker shades by changing HSL lightness.
- Save your palette in HEX, since it is the format used in most websites and design tools.
- Use the same values everywhere: website, social posts and logo. Our logo guide covers this.
- Test colours on a phone screen, in bright light and in dark mode.
Convert instantly
Use our free colour converter to switch between HEX, RGB and HSL in one click.
Lumaryx Digital Agency (Pakistan) helps businesses with Shopify stores, Meta and TikTok ads, SEO, email marketing and web development.
Talk to Lumaryx
Frequently asked questions
What does the # in a HEX colour mean?
It simply marks the value as a hexadecimal colour code. The six characters after it describe red, green and blue.
Which colour format should I use on a website?
HEX, RGB and HSL all work in CSS. HEX is the most common, and HSL is easiest for making lighter or darker shades.
What contrast ratio do I need?
WCAG guidance suggests at least 4.5:1 for normal text and 3:1 for large text.