Three ways to write the same colour
#3366CC = rgb(51, 102, 204) = hsl(220, 60%, 50%)
Type into any of the three fields and the other two update. HEX also accepts the three-digit short form, such as #36C, and RGB and HSL accept both the comma form and the newer space-separated CSS form.
How contrast is calculated
WCAG measures contrast from the relative luminance of each colour: how bright it appears, with green weighted most and blue least, because that is how the eye responds. The ratio compares the lighter colour with the darker one.
Contrast ratio = (L1 + 0.05) ÷ (L2 + 0.05)
L1 is the luminance of the lighter colour and L2 of the darker one. The result runs from 1:1 for two identical colours to 21:1 for black on white. The order does not matter.
Choosing accessible colours
- Check every text colour against every background it appears on, including hover and disabled states.
- Brand colours that are mid-tones often fail for small text. Use a darker shade for text and keep the brand colour for larger elements.
- Do not rely on colour alone to show meaning, such as red for an error; add an icon or a label too.
- Contrast also matters for charts, focus rings and input borders, which need at least 3:1 against their surroundings.