PRACTICAL GUIDE

Move Between HEX, RGB and HSL Colour Values

A six-digit HEX value uses two hexadecimal digits for each red, green and blue channel.

HEX and RGB describe the same channels

A six-digit HEX value uses two hexadecimal digits for each red, green and blue channel. Each pair spans 00 to FF, corresponding to integer channel values from zero to 255. Keep their order as red, green, blue.

Expand shorthand before reading it

In #369, each digit repeats: #336699. It is not the same as padding the three digits with zeros. Shorthand works only when each channel can be represented by a repeated hexadecimal digit.

Use HSL as another description

HSL expresses the colour as hue, saturation and lightness. For an achromatic grey, saturation is zero and hue is not visually meaningful; this tool reports zero for that hue. Display rounding can change a final decimal slightly.

Keep opacity and contrast separate

These inputs describe opaque sRGB colours. A transparent colour depends on what lies behind it, and readable contrast requires a foreground/background comparison. Converting one colour does not establish that a design is accessible.

Put it into practice