Gradients
Overview
CSS gradients are image-type values that transition smoothly between colors without raster assets, used for backgrounds, fills, and layered "mesh" effects. They are widely available (baseline since 2015). MDN documents the gradient data type and a practical usage guide. Read this when adding color washes, subtle depth, or decorative backgrounds in CSS.
Official sources
Core concepts
- linear-gradient() — colors progress along a straight line at a given angle or direction (MDN gradient).
- radial-gradient() — colors radiate outward from a center origin (MDN gradient).
- conic-gradient() — colors transition around a center point, useful for pie charts and color wheels (MDN gradient).
- Repeating variants —
repeating-linear-gradient(), repeating-radial-gradient(), repeating-conic-gradient() tile a gradient to fill the area (MDN gradient).
- Color stops & hints — positions control where colors land; hints adjust the midpoint of interpolation (MDN Using gradients).
- Layering / meshes — multiple gradients stacked in one
background (comma-separated) create mesh-like blends (MDN Using gradients).
- Premultiplied interpolation — gradients interpolate in alpha-premultiplied space to avoid muddy gray transitions (MDN gradient).
Best practices
- Stack several positioned radial gradients to approximate a soft "mesh" without images (MDN Using gradients — overlaying gradients).
- Place explicit color stops to control band placement and create hard lines when desired (MDN Using gradients).
- Use
background-blend-mode to mix layered gradients for richer results (MDN Using gradients).
- When fading to transparent, beware default interpolation muddiness — premultiplied space mitigates it, but verify the midpoint (MDN gradient).
Common pitfalls
- Fading a color to
transparent and getting a gray haze → fade to the same hue with 0 alpha (e.g., rgb(0 0 0 / 0)) instead of the keyword (MDN gradient interpolation note).
- Overusing high-contrast gradients behind text → keep washes subtle and check contrast of overlaid content.
- Forgetting repeating gradients exist for patterns → use
repeating-* instead of manually duplicating stops (MDN gradient).
Examples
/* Layered "mesh": multiple soft radial gradients stacked */
.hero {
background:
radial-gradient(40rem 40rem at 10% 20%, #6d5efc55, transparent 60%),
radial-gradient(30rem 30rem at 90% 30%, #00d4ff44, transparent 60%),
linear-gradient(160deg, #0b1020, #131a33);
}
Further reading
Related skills
- ../css-techniques — backgrounds and modern CSS context
- ../color-and-typography — choosing harmonious, accessible colors
1---2name: gradients3description: Tasteful CSS gradients — linear, radial, conic, repeating, and layered meshes; consult when adding depth or color washes to backgrounds.4domain: design5category: design6tags: [css, gradients, backgrounds, color, mesh]7official_sources:8 - https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_images/Using_CSS_gradients9 - https://developer.mozilla.org/en-US/docs/Web/CSS/gradient10verified: 2026-06-1611metadata:12 source: https://skillmd.com/skills/gabriel7silva/gradients13---1415# Gradients1617## Overview18CSS gradients are image-type values that transition smoothly between colors without raster assets, used for backgrounds, fills, and layered "mesh" effects. They are widely available (baseline since 2015). MDN documents the gradient data type and a practical usage guide. Read this when adding color washes, subtle depth, or decorative backgrounds in CSS.1920## Official sources21- MDN — Using CSS gradients (guide): https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_images/Using_CSS_gradients22- MDN — `<gradient>` data type: https://developer.mozilla.org/en-US/docs/Web/CSS/gradient2324## Core concepts25- **linear-gradient()** — colors progress along a straight line at a given angle or direction (MDN gradient).26- **radial-gradient()** — colors radiate outward from a center origin (MDN gradient).27- **conic-gradient()** — colors transition around a center point, useful for pie charts and color wheels (MDN gradient).28- **Repeating variants** — `repeating-linear-gradient()`, `repeating-radial-gradient()`, `repeating-conic-gradient()` tile a gradient to fill the area (MDN gradient).29- **Color stops & hints** — positions control where colors land; hints adjust the midpoint of interpolation (MDN Using gradients).30- **Layering / meshes** — multiple gradients stacked in one `background` (comma-separated) create mesh-like blends (MDN Using gradients).31- **Premultiplied interpolation** — gradients interpolate in alpha-premultiplied space to avoid muddy gray transitions (MDN gradient).3233## Best practices34- Stack several positioned radial gradients to approximate a soft "mesh" without images (MDN Using gradients — overlaying gradients).35- Place explicit color stops to control band placement and create hard lines when desired (MDN Using gradients).36- Use `background-blend-mode` to mix layered gradients for richer results (MDN Using gradients).37- When fading to transparent, beware default interpolation muddiness — premultiplied space mitigates it, but verify the midpoint (MDN gradient).3839## Common pitfalls40- Fading a color to `transparent` and getting a gray haze → fade to the same hue with `0` alpha (e.g., `rgb(0 0 0 / 0)`) instead of the keyword (MDN gradient interpolation note).41- Overusing high-contrast gradients behind text → keep washes subtle and check contrast of overlaid content.42- Forgetting repeating gradients exist for patterns → use `repeating-*` instead of manually duplicating stops (MDN gradient).4344## Examples45```css46/* Layered "mesh": multiple soft radial gradients stacked */47.hero {48 background:49 radial-gradient(40rem 40rem at 10% 20%, #6d5efc55, transparent 60%),50 radial-gradient(30rem 30rem at 90% 30%, #00d4ff44, transparent 60%),51 linear-gradient(160deg, #0b1020, #131a33);52}53```5455## Further reading56- MDN Using CSS gradients (overlaying, hints, blending): https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_images/Using_CSS_gradients57- MDN `<gradient>` reference: https://developer.mozilla.org/en-US/docs/Web/CSS/gradient5859## Related skills60- ../css-techniques — backgrounds and modern CSS context61- ../color-and-typography — choosing harmonious, accessible colors