Color codes: what's the difference?
The same purple can be written #7c3aed, rgb(124, 58, 237) or hsl(262, 83%, 58%). Each notation has its own use.
Ways to write screen colors
- HEX — #7c3aed. Red, green and blue as two hex digits each. The most common on the web and in design tools.
- RGB — rgb(124, 58, 237). The same values as numbers from 0 to 255.
- HSL — hsl(262, 83%, 58%). Hue (0–360°), saturation and lightness. Easy to make “a bit lighter” by hand.
- OKLCH — oklch(54% 0.24 293). Matched to human brightness perception: colors with the same lightness look equally bright, which is great for palettes.