CSS Gradient Generator: Linear and Radial Backgrounds

Choose colors, drag the angle and place each color stop. The preview repaints at once and the CSS line under it is ready to copy.

TechFreeNo sign-upWorks on phones
CSS to paste


This tool runs in your browser. Nothing you type is uploaded or saved, and there is nothing to install or sign up for.

A background that fades, without an image file

A gradient is a smooth blend from one color into another. In CSS it is drawn by the browser itself, so there is no picture to design, export, upload or wait for. One line of code can fill a page header, a button, a slide title bar or a certificate border, and it stays sharp at any size.

Writing that line by hand is fiddly, because you cannot see the result until you save and reload. This generator shows the blend while you adjust it and writes the matching background declaration for you. It handles the two kinds used most: linear (colors change along a straight line) and radial (colors spread outward from the center).

How to build your gradient

  1. Pick Linear or Radial with the switch.
  2. For a linear gradient, type a number in Angle or drag the Angle slider. With Radial selected, the Radial shape menu decides between a round Circle and a stretched Ellipse.
  3. Set Color 1 and Color 2 with the color pickers, and give each a Position (%) from 0 to 100.
  4. Press + Add a color stop for a third, fourth or fifth color. Remove stop deletes a row; two always remain.
  5. Press Copy CSS and paste the line into your stylesheet. Reset brings back the starting yellow-to-blue blend.

Short on ideas? Surprise me invents a random two or three color blend, and the four small buttons (Sky, Sunrise, Meadow, Dusk) load ready-made ones you can adjust.

Worked example: from two colors to three

The page opens with yellow #fcc915 at 0% and blue #2b6cb0 at 100%, running left to right. The code box reads:

background: linear-gradient(90deg, #fcc915 0%, #2b6cb0 100%);

Press + Add a color stop once. A white stop appears at 50%, and although it is the third row in the list, the generator slots it into the middle of the code because stops are written in order of position:

background: linear-gradient(90deg, #fcc915 0%, #ffffff 50%, #2b6cb0 100%);

Switch to Radial and the same three colors become rings, yellow in the middle and blue at the edge:

background: radial-gradient(circle, #fcc915 0%, #ffffff 50%, #2b6cb0 100%);

What the angle and the stops mean

The angle tells the browser which way the colors travel. CSS measures it like a compass rather than like a math-class protractor: according to the W3C CSS Images specification (read December 2026), 0deg points upward, 90deg points to the right, and bigger numbers turn clockwise.

AngleColors runSame as the keyword
0degbottom to topto top
90degleft to rightto right
180degtop to bottomto bottom
270degright to leftto left

A color stop is a color plus the point where it is at full strength. Between two stops the browser mixes evenly. Move a stop closer to its neighbor and that part of the fade becomes tighter; give two neighboring stops the same position and you get a hard line instead of a fade, which is how stripes are made.

In a radial gradient 0% is the center and 100% is the outer edge. Circle keeps the rings round whatever the shape of the box; Ellipse stretches them to match a wide or tall box. The angle has no effect on a radial gradient, so those two controls are switched off while Radial is selected.

Limits to know about

  • Two to five stops. That covers nearly every practical background. More colors usually look muddy.
  • Centered radials only. The generator does not write a custom center position or size keywords such as closest-side. You can add those by hand afterward.
  • No conic or repeating gradients. Those are separate CSS functions and are not produced here.
  • Solid colors. The pickers give six-digit HEX codes without transparency.
  • A gradient is an image, not a color. It belongs in background or background-image. Placing it in background-color or color does nothing.

One more thing to expect: a very long fade between two similar colors can show faint steps, known as banding, on some screens. Shortening the fade or choosing colors that differ more usually hides it.

A stop position outside 0 to 100, or an angle outside 0 to 360, brings up a message and the code keeps the last good value, so you never copy a broken line.

Tips for good-looking, readable gradients

Blends between neighbors on the color wheel (blue to teal, orange to pink) look calm. Blends between opposites, such as red and green, pass through a dull gray-brown in the middle; adding a lighter third stop at 50% usually rescues them.

If words sit on top, readability comes first. Run your text color against both the lightest and the darkest end of the blend in the color contrast checker, since a heading that reads well on the dark side can vanish on the light side. Need colors that belong together? Start with the color palette generator and carry its codes over.

For a class project website, a gradient header plus a soft shadow from the CSS box shadow generator gives a card a finished look with two lines of CSS. When a design tool gives you red, green and blue numbers, the RGB to HEX converter turns them into the six-digit codes the pickers use.

You will find the rest of the web and tech tools in one group, and every calculator and helper on the list of free online tools.

Frequently asked questions

How do I make a gradient background in CSS?

Set the background property to a gradient function, for example background: linear-gradient(90deg, #fcc915 0%, #2b6cb0 100%); The generator writes this line for you from the colors and angle you choose.

What is the difference between a linear and a radial gradient?

A linear gradient changes color along a straight line at the angle you set. A radial gradient starts at the center and changes color outward in circles or ellipses.

Which way does 90deg point in a CSS gradient?

To the right. CSS gradient angles start at 0deg pointing up and increase clockwise, so 90deg runs left to right and 180deg runs top to bottom.

How many colors can a CSS gradient have?

CSS itself needs at least two color stops and sets no small upper limit. This generator lets you use from two to five, which keeps the blend clean.

Why is my gradient not showing?

The most common cause is putting it in background-color, which accepts only a single color. Use background or background-image, and make sure the element has a height.

Related tools

Browse all free tools →