CSS Gradient Generator

Build a CSS gradient visually and copy the code.

CSS Gradient Generator tool

Colour stops

CSS

About the CSS Gradient Generator

Gradients add depth to backgrounds, buttons and banners without loading an image. This CSS gradient generator lets you build linear or radial gradients by eye: choose the angle or shape, add as many color stops as you need, set each stop's position and watch a large preview update. When it looks right, copy the CSS straight into your stylesheet. Subtle gradients between two related shades usually look more professional than strong rainbow effects, and checking text contrast over the lightest and darkest parts keeps content readable. For choosing harmonious colors, use the Color Palette Generator, and for exact codes, the Color Picker.

Each colour stop has two settings: its colour and its position along the gradient as a percentage. Once you add more than two stops, the gradient stops looking like a default and starts looking designed, because you can hold one colour for most of the area and let the change happen late, so the blend no longer sits exactly halfway.

The finished code appears as a complete background declaration that you can paste straight into a stylesheet, a style attribute or a design token file, with no clean-up needed. When ideas run dry, the random button produces a new combination, and the reverse button flips the direction of the colours in one click, a fast test of whether the design reads better when the colours run in the opposite order.

How to use the CSS Gradient Generator

  1. Pick the typeA straight linear gradient set by an angle, or a radial one that spreads out from the centre as a circle or ellipse.
  2. Set the colour stopsAdjust each stop's colour and position, adding or removing stops until the blend looks right.
  3. Watch the previewThe large preview updates with every change you make.
  4. Copy the codeThe full CSS background declaration is ready to paste.

CSS Gradient Generator features

  • Linear gradients at any angle, plus radial gradients
  • Two or more colour stops with their own positions
  • Stops can be added, removed and reordered
  • A large preview that updates live
  • Reverse the colour order with one click
  • Random gradients for inspiration
  • Produces a ready-to-use background rule for your stylesheet

Common uses

  • Designing the background of a landing page hero section
  • Adding a gentle gradient to buttons or cards
  • Making a colourful placeholder without an image file
  • Trying colour combinations quickly by eye
  • Creating a gradient from a company's brand colours

Gradients in practice: an Independence Day banner, overlays for readable text, muddy middles, progress rings, stripes and printing

By the FreeToolsWorld editorial team · Updated November 2026 · How we write and check our guides

Gradients add depth and energy to banners, buttons and backgrounds without the weight of images. They also bring their own pitfalls, from text that becomes unreadable at one end to dull grey bands in the middle. This guide designs an Independence Day banner and covers overlays for text on photos, smoother colour blending, conic progress rings, repeating stripes and printing.

A worked example: an Independence Day banner

A shop's sale banner uses a gradient from the deep flag green #01411C to a brighter green #0B8A4A at 135 degrees, with white text. White on the dark end has excellent contrast, about 11.8 to 1, but on the bright end only about 4.4 to 1, just under the 4.5 needed for normal text. The headline is large and bold, where 3 to 1 suffices, but the small print is moved over the darker part of the gradient.

Overlays for text on photos

A gradient from semi-transparent black to transparent, such as linear-gradient(to top, rgba(0,0,0,.6), transparent), placed over the bottom of a photo, darkens only the area where captions sit. It keeps text readable on any image while leaving the rest of the photo bright. This is far more reliable than relying on text shadows alone.

Avoiding muddy middles

Blending two very different colours, such as blue and orange, in the default colour space can produce a dull grey band in the middle. Modern CSS lets gradients blend in other colour spaces, for example linear-gradient(in oklch, blue, orange), which keeps the middle vivid. Adding a deliberate middle colour stop is another fix that works everywhere.

Progress rings with conic gradients

Conic gradients sweep colours around a centre point, which makes progress rings and simple pie charts possible without images. A background such as conic-gradient(#16a34a 0 72%, #e5e7eb 0) shows 72 percent complete. Placing a smaller circle on top turns the pie into a ring, and changing the percentage with a variable animates progress.

Stripes with repeating gradients

Repeating linear gradients with hard colour stops create stripes, useful for progress bars, highlighted sale labels or placeholder backgrounds. Because the pattern is generated by CSS, it stays sharp at every size and costs no extra download.

Lightweight and sharp

Gradients are drawn by the browser, so they scale perfectly on any screen and add almost nothing to page weight compared with background images. Replacing large gradient images with CSS gradients is an easy speed improvement for older sites.

Brand gradients

If a brand uses gradients, define them once as custom properties with fixed angles and colour stops, and reuse them everywhere. Gradients improvised separately on each page quickly drift apart and weaken the brand's look.

Printing

Browsers often skip background colours and gradients when printing unless the user enables background graphics. Designs that place important text on gradient backgrounds should include print styles that switch to plain backgrounds and dark text.

Common mistakes

  • Checking text contrast only against the dark end.
  • Accepting dull grey bands between contrasting colours.
  • Using large images where a CSS gradient would do.
  • Relying on gradients for content in printed pages.

Related tools

To choose harmonious colour stops, use Color Palette Generator. For frosted panels over gradients, try Glassmorphism Generator, and to check text at both ends, Color Contrast Checker.

Gradient borders

A gradient border can be made with border-image, set to a linear gradient with a slice value of 1. Border images do not follow rounded corners, so for rounded elements a common alternative layers a gradient background behind a slightly smaller inner element. Both techniques avoid exporting borders as images.

Gentle animation

Animating a large gradient's background position creates a slow, shifting effect for hero sections. Keep it subtle and slow, and switch it off for visitors who prefer reduced motion, using the prefers-reduced-motion media query. Constant movement can distract readers and drain battery on phones.

Split backgrounds with hard stops

Placing two colour stops at the same position creates a hard edge instead of a blend. A background such as linear-gradient(90deg, #ffffff 50%, #f3f4f6 50%) splits a section into two tones, useful for layouts with text on one side and an image or form on the other.

Gradients in emails

Many email clients ignore CSS gradients. Always set a solid background colour first, close to the gradient's average, so clients that drop the gradient still show an attractive, readable background. Test the email in several clients before sending.

Exporting for social media

When a gradient is exported as an image for social media, compression can introduce visible bands. Exporting as PNG, or adding a very light noise texture before saving as JPEG, keeps the blend smooth after platforms recompress the image.

Keep a fallback colour

Always declare a plain background colour before the gradient in your CSS. If the gradient fails to load or is not supported, visitors still see a suitable colour, and text placed on top keeps the contrast you checked.

Privacy

Gradients are generated and previewed in your browser. Nothing is uploaded or stored.

Frequently asked questions

What does the angle of a linear gradient mean?

It sets the direction the colours travel, in degrees. 0 degrees runs from bottom to top, 90 degrees from left to right and 180 degrees from top to bottom, the direction most page backgrounds use.

How many colour stops should a gradient have?

Two is the default and is often enough. Three or four give you control over where the change happens, for example keeping most of the area one colour. Many more stops tend to look muddy rather than rich.

Will my gradient work in every browser?

Yes, linear and radial gradients work in every browser people use today. Only very old browsers need a safety net, which is simply a plain colour written on the line above the gradient so they have something to show.

Why does my gradient show visible bands?

Stripes appear when the start and end colours are nearly the same brightness and the display has too few in-between steps to draw a smooth blend. Choosing colours with a bigger difference in lightness, or laying a faint texture over the top, usually smooths it out.

Is it possible to fill lettering with a gradient?

Yes: give the heading the gradient as its background, then mask it to the letter shapes with background-clip: text and a transparent text colour. This tool generates the gradient itself, which you can then paste into that technique.

Does the code need vendor prefixes?

No. Prefixes such as -webkit- were needed many years ago, but every current browser understands the standard syntax, so adding them now only makes the stylesheet longer.