Design · 7 min read

CSS Gradients: A Practical Guide for Modern Web Design

Linear, radial, conic, and the new mesh gradients — when each one wins, plus the OKLCH color trick that makes gradients look professional instead of muddy.

By Syed Husnain Haider Bukhari · · Updated

CSS gradients are the most underused tool in modern UI design. Used well, they add depth, focus, and warmth without a single image asset. Used poorly, they produce the muddy purple-to-orange diagonals that screamed "web 2.0" in 2008. The difference between the two is mostly about color interpolation, color choice, and knowing which gradient type fits each job.

This guide is a practical walkthrough of every gradient type CSS supports in 2026, the tricks that separate professional gradients from beginner ones, and the patterns that show up in every modern design system.

Linear gradients: the workhorse

Linear gradients interpolate color along a straight line: `linear-gradient(135deg, #6366f1, #ec4899)`. They work everywhere — backgrounds, borders, text fills, masks — and are the right answer for hero sections, button highlights, and subtle background depth.

Two pro tricks. First, prefer short angle distances (15deg from horizontal or vertical) for backgrounds, not perfect diagonals — the angle is more visible and feels more intentional. Second, add a third stop close to the start or end to control where the transition concentrates: `linear-gradient(135deg, #6366f1 0%, #6366f1 30%, #ec4899 100%)` keeps the gradient mostly blue with a punch of pink in the corner.

Radial gradients: focus and depth

Radial gradients emanate from a single point. They're perfect for spotlight effects, button glows, and creating the illusion of light sources. `radial-gradient(circle at top left, rgba(99,102,241,0.4), transparent 60%)` overlaid on a dark background gives you a soft glow in the corner — the foundation of every modern dark-mode hero section.

Use `at <position>` to control where the gradient originates. Use `ellipse` instead of `circle` for elongated effects. Combine multiple radial gradients in a single background declaration (CSS lets you stack them) for complex lighting setups.

Conic gradients: pie charts and rotation

Conic gradients sweep color around a center point: `conic-gradient(red, yellow, green, blue, red)`. They're useful for pie chart visualizations, loading spinners, and creative angular effects that linear gradients can't produce.

A common UI pattern is the "angle glow" — a conic gradient with a single bright color that fades into transparency, rotated behind a card to suggest depth or motion. Combine with `mask` and `border-image` for premium UI accents.

OKLCH interpolation: the gradient revolution

Most browsers default to interpolating gradients in sRGB color space, which produces dull or muddy transitions through colors like brown or gray. CSS Color 4 lets you specify the interpolation color space: `linear-gradient(in oklch, #6366f1, #ec4899)`. Suddenly the same color stops produce a vibrant, even transition with no dead zone in the middle.

The difference is dramatic on blue-to-yellow or red-to-green gradients. Always use `in oklch` (or `in oklab`) for vibrant brand gradients. Use the default sRGB only when you specifically want the muted look.

Mesh gradients: the newest tool

Mesh gradients — multiple radial or conic gradients composited together — produce organic, abstract backgrounds that look like watercolor or smoke. They're the dominant aesthetic on modern landing pages for 2024-2026, replacing the flat color trend of the late 2010s.

There's no single CSS property for mesh gradients yet. The trick is layering three to six radial gradients with different colors and positions in a single `background` declaration: `background: radial-gradient(circle at 20% 30%, #6366f1 0%, transparent 50%), radial-gradient(circle at 80% 70%, #ec4899 0%, transparent 50%), #0d0d0d;`. Adjust positions and colors until you get the desired feel.

Text gradients

Apply a gradient to text by combining `background`, `background-clip: text`, and `-webkit-text-fill-color: transparent`. The result is a gradient-filled headline, popular for marketing pages and product reveals.

Use this sparingly. Gradient text reduces contrast, which can fail WCAG AA checks. Reserve it for short, decorative headlines, not body text. Always test that the gradient endpoints still meet a minimum contrast ratio against the background.

Performance and accessibility

Gradients render very efficiently — they're computed by the GPU and don't have file overhead like images do. However, complex multi-stop gradients animated with `background-position` can cause repaints on every frame; prefer transform-based animation instead.

Accessibility: text on top of a gradient must still meet contrast requirements at every pixel under the text, not just the average. Add a semi-transparent solid overlay if needed: `linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5)), url('photo.jpg')` darkens a hero photo enough to keep text readable.

Three gradient patterns that always work

  • Subtle vertical shift — `linear-gradient(180deg, #0d0d0d, #1a1a1a)` as a page background; adds depth without distraction.
  • Corner glow — `radial-gradient(circle at top right, rgba(99,102,241,0.3), transparent 50%)` overlaid on a dark hero; suggests light without an image.
  • Brand sweep — `linear-gradient(135deg in oklch, #6366f1, #ec4899)` on a button or feature card; vibrant and modern.

Wrapping up

Gradients are cheap, fast, and powerful when used with intention. Pick the right type for the job, interpolate in OKLCH, mind your contrast, and don't be afraid to layer multiple radial gradients for organic backgrounds. The aesthetic instincts come from looking at lots of well-designed sites and figuring out which patterns they use.

Our free gradient generator produces linear, radial, and conic gradients with live preview, OKLCH interpolation, and CSS output you can paste straight into your project. Build a hero background in 30 seconds.