HEX, RGB, HSL, OKLCH, LAB, CMYK, HSV — if you've ever gotten lost in the alphabet soup of color formats, you're not alone. Each format exists for a reason, and using the wrong one for the job creates subtle bugs that are pure hell to debug.
The worst: you set a color in HEX, tweak it in HSL in devtools, copy it back as RGB, and now your design tokens don't match. Here's the definitive guide to color format conversions — when to use each, and why.
CSS Color Level 4 (widely supported in 2026) added OKLCH, LAB, and display-p3 color spaces to the web platform. You can now use colors that were previously only possible in design tools like Figma.
The infamous "wrong blue" bug: A developer copied a blue from Figma as HEX (#4F46E5) but the exported CSS used RGB. The subtle rounding error (0-255 integer rounding in RGB) shifted the hue by 2°, making the deployed version slightly purple. It took 3 days to find.
Stripe's internal tooling enforces HSL-only color definitions. HEX and RGB are banned from design tokens. This lets them compute accessibility scores, generate dark variants, and handle opacity programmatically without conversion bugs.
CSS Color Level 4 (widely supported in 2026) added OKLCH, LAB, and display-p3 color spaces to the web platform. You can now use colors that were previously only possible in design tools like Figma.
The infamous "wrong blue" bug: A developer copied a blue from Figma as HEX (#4F46E5) but the exported CSS used RGB. The subtle rounding error (0-255 integer rounding in RGB) shifted the hue by 2°, making the deployed version slightly purple. It took 3 days to find.
Stripe's internal tooling enforces HSL-only color definitions. HEX and RGB are banned from design tokens. This lets them compute accessibility scores, generate dark variants, and handle opacity programmatically without conversion bugs.
CSS Color Level 4 (widely supported in 2026) added OKLCH, LAB, and display-p3 color spaces to the web platform. You can now use colors that were previously only possible in design tools like Figma.
The infamous "wrong blue" bug: A developer copied a blue from Figma as HEX (#4F46E5) but the exported CSS used RGB. The subtle rounding error (0-255 integer rounding in RGB) shifted the hue by 2°, making the deployed version slightly purple. It took 3 days to find.
Stripe's internal tooling enforces HSL-only color definitions. HEX and RGB are banned from design tokens. This lets them compute accessibility scores, generate dark variants, and handle opacity programmatically without conversion bugs.
CSS Color Level 4 (widely supported in 2026) added OKLCH, LAB, and display-p3 color spaces to the web platform. You can now use colors that were previously only possible in design tools like Figma.
The infamous "wrong blue" bug: A developer copied a blue from Figma as HEX (#4F46E5) but the exported CSS used RGB. The subtle rounding error (0-255 integer rounding in RGB) shifted the hue by 2°, making the deployed version slightly purple. It took 3 days to find.
Stripe's internal tooling enforces HSL-only color definitions. HEX and RGB are banned from design tokens. This lets them compute accessibility scores, generate dark variants, and handle opacity programmatically without conversion bugs.
用这些免费工具实操你学到的知识: