CSS Color Formats
Complete guide to CSS color formats — HEX, RGB, HSL, OKLCH, named colors, transparency, and color-mix().
Overview
CSS supports many color formats, each with different strengths. Hexadecimal (#RRGGBB) is compact and widely used. RGB (rgb(R, G, B)) maps directly to screen output. HSL (hsl(H, S%, L%)) is intuitive for creating palettes. Newer formats like OKLCH provide perceptually uniform color manipulation. Understanding when to use each format helps create accessible, maintainable designs.
Syntax
color: <color-value>Values
Browser Support
HEX, RGB, HSL: universal. OKLCH: Chrome 111+, Firefox 113+, Safari 15.4+. color-mix(): Chrome 111+, Firefox 113+, Safari 16.2+.
Try it visually
Use our visual color generator to create and preview CSS code in real-time.
Open CSS Color Formats ToolFrequently Asked Questions
Use HSL for design tokens and palette creation (easy to adjust lightness/saturation). Use HEX for static values in code. Use OKLCH if you need perceptually uniform scales.
Use the / alpha syntax: `rgb(255 0 0 / 0.5)`, `hsl(0 100% 50% / 0.5)`, or 8-digit hex: `#ff000080`.
A keyword that resolves to the element's computed `color` property. Useful for making borders, shadows, and SVGs inherit the text color.