CSS Gradient Guide 2026: Every Type Explained

By IWantFreeColorTools.com

By IWantFreeColorTools.com · 8 min read

Quick Answer

CSS gradients are smooth color transitions created in code instead of images, using linear-gradient, radial-gradient, or conic-gradient. They load fast, scale cleanly, and are easy to edit, which is why designers use them for backgrounds, buttons, and text effects. All three types work in every modern browser as of 2026.

CSS gradients let you create smooth color transitions in pure code, with no image file needed. There are three types, and by 2026 all of them work in every modern browser: linear-gradient for straight-line blends, radial-gradient for circular ones, and conic-gradient for colors that sweep around a point. Because they are code, gradients scale to any size at zero file weight and change with a single value. This guide covers each type with copy-paste examples, the popular gradient text trick, browser support, and performance, all backed by the official docs on MDN Web Docs.

What are CSS gradients and why use them?

A CSS gradient creates a smooth transition between two or more colors using pure CSS, with no image file required (W3C CSS Images). There is no image file to download, a gradient scales to any size, and you change it by editing a value.

You see them everywhere in modern web design: hero backgrounds, button hover effects, card surfaces, text fills, photo overlays, loading skeletons, and small decorative accents. Learning to write them by hand means you can produce any gradient effect without opening a design tool or exporting an image.

🌈 Build linear, radial and conic gradients with our free gradient generator.

How do linear gradients work?

A linear gradient transitions colors along a straight line at an angle you choose. It is the most common type by far.

Basic syntax

background: linear-gradient(direction, color1, color2);

Direction options

/* Keyword directions */
background: linear-gradient(to right, #7C3AED, #06B6D4);
background: linear-gradient(to bottom right, #7C3AED, #06B6D4);

/* Degree angles */
background: linear-gradient(90deg, #7C3AED, #06B6D4); /* left to right */
background: linear-gradient(135deg, #7C3AED, #06B6D4); /* diagonal */

Per MDN, when you leave out the direction a linear gradient runs top to bottom, and with angles, 90deg goes left to right while 0deg goes bottom to top, rotating clockwise.

Multiple color stops

/* Three colors with positions */
background: linear-gradient(90deg,
#7C3AED 0%,
#06B6D4 50%,
#10B981 100%
);

/* Hard stop for a sharp edge */
background: linear-gradient(to right, #7C3AED 50%, #06B6D4 50%);

Color stops can sit at any percentage, so you can make uneven blends or create hard edges by placing two stops at the same position.

How do radial gradients work?

A radial gradient spreads colors outward from a center point in a circular or elliptical shape. As MDN describes it, the colors transition from the center of an ellipse outward in every direction.

/* Basic circle */
background: radial-gradient(circle, #7C3AED, #1e1b4b);

/* Custom center position */
background: radial-gradient(circle at 30% 40%, #7C3AED, #1e1b4b);

/* With a size keyword */
background: radial-gradient(circle closest-side, #7C3AED, #1e1b4b);

Radial gradients suit spotlight effects, glowing backgrounds, and any composition where a soft burst of color from a point looks right. Moving the center with the "at" keyword lets you place off-center focal points.

What are conic gradients for?

A conic gradient rotates colors around a center point, like a color wheel or a pie chart. MDN puts it neatly: the colors transition as if spun around the center of a circle, starting at the top and going clockwise.

/* Basic conic gradient */
background: conic-gradient(from 45deg, #7C3AED, #06B6D4, #10B981, #7C3AED);

/* Pie chart style with hard stops */
background: conic-gradient(
#7C3AED 0deg 120deg,
#06B6D4 120deg 240deg,
#10B981 240deg 360deg
);

Conic gradients are great for pie charts using hard color stops at set degrees, color wheel visuals, and radial loading indicators. They are the newest of the three, but as covered below, support is now everywhere.

How do you choose the color space a gradient blends in?

Add a color interpolation method, which CSS Images Level 4 adds to the gradient functions. MDN gives its form as in followed by a rectangular space such as oklab, or a polar space with an optional hue method. It can sit either side of the direction, so in oklab to right and MDN's 90deg in oklab are both valid.

background: linear-gradient(to right, #f01, #081);
background: linear-gradient(in oklab to right, #f01, #081);

Keep the plain line first. CSS 2.1 says user agents must ignore a declaration with an illegal value, so a browser that cannot parse the second line keeps the first.

Without a method, CSS Color Level 4 defaults to Oklab, except that gradients between legacy sRGB formats (hex colors, named colors, rgb(), hsl() or hwb()) blend in gamma-encoded sRGB. That is why a hex gradient can go grey in the middle; the design side is in our gradient design guide.

Hue methods for polar spaces

The polar spaces are hsl, hwb, lch and oklch. They accept shorter hue (the default), longer hue, increasing hue and decreasing hue. Rectangular spaces such as Oklab have no hue method, so in oklab longer hue is not valid.

background: linear-gradient(to right, #06f, #f80);
background: linear-gradient(in oklch longer hue to right, #06f, #f80);

If one end is white, black or grey, its hue is missing, and the spec gives a missing component the other color's value, so there is no arc to choose.

How do you move a gradient's midpoint with a color hint?

Put a bare length or percentage between two stops. CSS Images 4 defines a color transition hint as "a position between two color stops representing the halfway point in the color transition".

background: linear-gradient(in oklab to right, #4338ca, 30%, #22d3ee);

Here the halfway color lands 30% of the way across. CSS Images Level 3 notes that a hint exactly halfway between its stops produces ordinary linear interpolation, so 50% changes nothing.

Gradients also interpolate with premultiplied alpha, which CSS Images 3 says "tends to produce more attractive transitions", and the difference from non-premultiplied blending only arises when both the color and the transparency differ between the two ends.

How do repeating and tiled gradients work?

repeating-linear-gradient(), repeating-radial-gradient() and repeating-conic-gradient() take the same values as their non-repeating siblings. In CSS Images 3, the color stops then repeat infinitely in both directions, shifted by multiples of the distance between the first and last stop.

/* a 40px cycle with a hard seam */
background: repeating-linear-gradient(red 10px, blue 50px);

/* end on the opening color for a soft repeat */
background: repeating-linear-gradient(red 0, blue 20px, red 40px);

The first and last stops meet at every cycle boundary, which the spec says "will produce sharp transitions if the gradient does not start and end with the same color". Keep the seam for stripes; close the loop for a soft wash.

To tile an ordinary gradient, give it a size. A gradient has no natural dimensions, and CSS Backgrounds Level 3 sizes such an image "as for contain", so it fills the box and background-repeat has nothing to repeat. With round, the spec rescales the tile so a whole number of them fits.

background: linear-gradient(45deg, #ede9fe, #f5f3ff);
background-size: 40px 40px;
background-repeat: round;

How do you derive gradient stops from one brand color?

Use relative color syntax from CSS Color Level 5: start a color function with from <color>, then refer to the origin's channels by keyword, which in oklch() are l, c, h and alpha. Omitted alpha defaults to the origin's, and color components are not clamped, so check what an aggressive calc() resolves to.

.hero {
--brand: #4338ca;
--soft: oklch(from var(--brand) calc(l + 0.12) calc(c * 0.85) h);
background: linear-gradient(to right, #4338ca, #6268e2);
}
@supports (color: oklch(from red l c h)) {
.hero {
background: linear-gradient(in oklab to right, var(--brand), var(--soft));
}
}

The hard-coded #6268e2 is that derived color converted to hex. Use a feature query here rather than two background lines: CSS Variables Level 1 says a declaration containing var() is assumed valid at parse time, so it beats the fallback line in the cascade, and if substitution then fails the property is invalid at computed-value time.

For a middle stop, color-mix() blends two colors and, per CSS Color 5, assumes Oklab when no interpolation method is given. Choosing the brand color itself is covered in the gradient design guide.

How do you make gradient text?

One of the most popular gradient tricks is applying a gradient to text. It takes three properties working together:

.gradient-text { color: #7C3AED; } /* solid fallback */
@supports (background-clip: text) or (-webkit-background-clip: text) {
.gradient-text {
background: linear-gradient(90deg, #7C3AED, #06B6D4);
-webkit-background-clip: text;
background-clip: text;
color: transparent;
}
}

This clips the gradient to the shape of the text and makes the text itself transparent so the gradient shows through. Can I Use lists background-clip: text as supported in every current major browser; the -webkit- line covers older versions. The @supports block matters: setting color: transparent without it would make the text invisible in a browser that cannot clip the background, so the solid colour outside the block is the fallback. For contrast on gradient text, see the gradient design guide.

🌈 Try linear, radial and conic gradients in our free gradient generator.

How do gradients behave in forced colors mode?

They are removed. In CSS Color Adjustment Level 1, background-image computes to none in forced colors mode unless it contains a url(), and box-shadow and text-shadow compute to none. Gradient text loses the gradient it was showing through, so give it a plain system color there:

@media (forced-colors: active) {
.gradient-text {
background: none;
color: CanvasText;
}
}

The forced-colors media feature in Media Queries Level 5 matches active when the browser enforces a user-chosen limited palette, and CanvasText is the CSS Color 4 system color for text in documents. forced-color-adjust takes auto, none or preserve-parent-color; use none sparingly, for the reasons in the gradient design guide.

How do you animate gradient colors?

Store the colors in custom properties and register them with @property. The CSS Properties and Values API Level 1 says registered values "interpolate by computed value, in accordance with the type that they parsed as".

@property --stop-one {
syntax: "<color>";
inherits: false;
initial-value: oklch(70% 0.15 250);
}
.hero {
background: linear-gradient(in oklab to right, var(--stop-one), #22d3ee);
transition: --stop-one 0.6s;
}

syntax and inherits are required, and initial-value is required for any syntax other than "*". It must be computationally independent: the spec's example is that 3em is not, because it relies on font-size. MDN lists @property as Baseline 2024, newly available since July 2024, and notes it might not work in older devices or browsers.

Cost depends on what moves. MDN explains that properties which do not affect geometry and are not in their own layer trigger a style recalculation and a repaint, while transform and opacity are handled in composition without a repaint. So changing a gradient repaints each frame; cross-fading two gradient layers with opacity, or moving an oversized one with transform, avoids that. Turn it off for people who ask:

@media (prefers-reduced-motion: reduce) {
.hero { animation: none; transition: none; }
}

WCAG's Pause Stop Hide rule still applies to looping backgrounds; see animated gradients in the design guide.

Which gradient patterns are most useful?

Hero overlay on an image

.hero {
background-image:
linear-gradient(to bottom, rgba(0,0,0,0), rgba(0,0,0,0.7)),
url('hero-image.jpg');
background-size: cover;
}

Subtle card background

.card {
background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%);
}

Button hover gradient

.btn { background: #7C3AED; transition: background 0.2s; }
.btn:hover { background: linear-gradient(135deg, #7C3AED, #06B6D4); }

These three cover most day-to-day needs. If you want to see how gradients fit the wider palette conversation, our CSS color formats guide and the 2026 web design color trends are worth a read.

Do gradients work in every browser and perform well?

Support is excellent. Linear and radial gradients have been baseline features for over a decade. Conic gradients are the newest, but they are fully supported now too. According to Can I Use, conic-gradient works in Chrome 69 and up, Edge 79 and up, Firefox 83 and up, and Safari 12.1 and up, which covers every current desktop and mobile browser. For very old browsers, a solid color fallback is all you need.

On performance, a gradient needs no image download. The one caution is animation. Gradients on elements that change constantly can cause repaints, so for animated elements prefer solid colors and animate opacity or transform instead of the gradient itself. Mesh gradients, which stack several radial gradients, look stunning but cost more to render, so test them on a low-end phone before using them in scroll animations.

What else do people ask?

What is the CSS syntax for a linear gradient?

The basic syntax is background: linear-gradient(direction, color1, color2). Direction can be a keyword like to right or to bottom, or a degree value like 90deg or 135deg. You can add multiple color stops, such as linear-gradient(90deg, #7C3AED 0%, #06B6D4 50%, #10B981 100%). When you leave out the direction, it defaults to top to bottom, which is 180deg.

How do I make a gradient background in CSS?

Use the background or background-image property with a gradient function. For example, background: linear-gradient(135deg, #7C3AED, #06B6D4) creates a purple to cyan gradient at 135 degrees. Use background-image instead of background when you also need to set background-size or background-position separately.

Can I animate a CSS gradient?

Not directly, because gradients are treated as images and cannot be transitioned. The common workaround is to animate background-position on an oversized gradient, or fade between pseudo-elements with different gradient backgrounds. Animating background-position repaints on every frame, so fading a pseudo-element's opacity is usually the lighter option.

Do conic gradients work in all browsers?

Yes, in every modern browser. According to Can I Use, conic-gradient is supported in Chrome 69 and up, Edge 79 and up, Firefox 83 and up, and Safari 12.1 and up, which covers all current desktop and mobile browsers. For very old browsers, provide a solid color fallback.

How many colors can a CSS gradient have?

There is no practical limit. You can add as many color stops as you like, each with an optional position, such as linear-gradient(90deg, red 0%, orange 25%, yellow 50%, green 75%, blue 100%). More stops give you finer control, though simple two or three color gradients usually look cleanest and perform best.

Sources: MDN Web Docs, Using CSS gradients (developer.mozilla.org/en-US/docs/Web/CSS/Guides/Images/Using_gradients). MDN Web Docs, conic-gradient() (developer.mozilla.org). Can I Use, CSS Conical Gradients (caniuse.com/css-conic-gradients). Can I Use, Background-clip: text (caniuse.com/background-clip-text). W3C, CSS Images Module Level 3 (w3.org/TR/css-images-3). W3C, CSS Images Module Level 4 (w3.org/TR/css-images-4). W3C, CSS Color Module Level 4 (w3.org/TR/css-color-4). W3C, CSS Color Module Level 5 (w3.org/TR/css-color-5). W3C, CSS Backgrounds and Borders Module Level 3 (w3.org/TR/css-backgrounds-3). W3C, CSS Custom Properties for Cascading Variables Module Level 1 (w3.org/TR/css-variables-1). W3C, CSS 2.1 Syntax and basic data types (w3.org/TR/CSS21/syndata.html). W3C, CSS Color Adjustment Module Level 1 (w3.org/TR/css-color-adjust-1). W3C, Media Queries Level 5 (w3.org/TR/mediaqueries-5). W3C, CSS Properties and Values API Level 1 (w3.org/TR/css-properties-values-api-1). MDN Web Docs, linear-gradient() (developer.mozilla.org/en-US/docs/Web/CSS/Reference/Values/gradient/linear-gradient). MDN Web Docs, @property (developer.mozilla.org/en-US/docs/Web/CSS/Reference/At-rules/@property). MDN Web Docs, Animation performance and frame rate (developer.mozilla.org/en-US/docs/Web/Performance/Guides/Animation_performance_and_frame_rate).

Get fresh reads straight to your inbox

Get notified when we publish new articles. Unsubscribe anytime.