How named colors work
CSS defines 148 color keywords, such as crimson and steelblue. Each one maps to a fixed sRGB value, so a keyword and its hex code give exactly the same color in every browser.
Choosing between hex, RGB and HSL
- Hex is the most compact and the usual choice in design tools.
- RGB is useful when you need an alpha channel, for example
rgb(220 20 60 / 50%). - HSL is the easiest to adjust by hand: change the hue to rotate around the wheel, lightness to make it lighter or darker.
Check contrast before you ship
Text needs a contrast ratio of at least 4.5:1 against its background to meet WCAG AA (3:1 for large text). Each color page lists its ratio against white and black.