W3C CSS Images & Gradient Mathematics
CSS gradients are classified as <image> data types under the W3C CSS Images Module Level 3 specification. Rather than loading external bitmap images (PNG, JPEG) that incur network latency and storage overhead, gradients are rendered dynamically by browser graphics engines via GPU mathematical rasterization.
Gradient Types Specification Comparison
| Gradient Type | Core Syntax | Progression Trajectory | Primary UI Applications |
|---|---|---|---|
| Linear | linear-gradient(angle, stop1, stop2) | Straight directional line | Hero banners, button backgrounds, card borders |
| Radial | radial-gradient(shape at pos, stop1, stop2) | Concentric circles or ellipses | Spotlight glows, ambient vignette backdrops |
| Conic | conic-gradient(from angle, stop1, stop2) | 360-degree rotational sweep | Pie charts, color wheels, circular progress rings |
Color Interpolation in sRGB vs Perceptual Spaces
When transitioning between complementary hues (such as red and cyan, or blue and yellow), standard sRGB interpolation averages RGB color channels linearly. This creates an unappealing murky desaturation in the middle. The modern CSS Color Module Level 4 specification addresses this by supporting perceptual color spaces such as OKLCH and Oklab:
The in oklch interpolation directive preserves perceived brightness and chromatic saturation across the entire transition line.