ShareYourGroupShareYourGroupCSS Lab

CSS gradient generator

Pick the type, move the sliders, choose colours, and copy the line of CSS. The picture updates as you change anything.

What each control does

How to use the code

Copy the line and put it inside a rule for the element you want to colour, for example .hero { background: ...; }. The code is a normal background declaration, so it replaces a background colour or picture on that element. Add a plain background-color just before it if you want a colour to show where the gradient cannot be drawn.

Text on top of a gradient must stay readable at every point of the gradient, not only at one end. Check the lightest and the darkest area against your text colour.

Common mistakes

  1. Writing colour names the page does not know. The tool uses hex colours such as #ff7e5f, which every browser reads.
  2. Expecting 0deg to point right. In CSS it points up, which is different from the angles used in maths.
  3. Forgetting that a gradient is an image, not a colour. It belongs in background or background-image, not in background-color or color.
  4. Using it as text colour. To colour text with a gradient you need background-clip: text and a transparent text colour; the guide on gradients shows the lines.
Is the generated code safe to use in production?

Yes. The gradient functions are part of CSS and are understood by every current browser. We tested the three types in Chrome, in the engine used by Safari (WebKit) and in Firefox on 13 November 2026.

Can I use more than three colours?

Copy the code and add stops by hand: after the last colour write a comma and another colour with its position. The guide explains the syntax.

Does the tool save my colours?

No. Nothing you do on this page is stored or sent anywhere.

This is an independent site. It is not connected with the W3C, MDN, Google, Apple, Mozilla or Microsoft. Browser and product names belong to their owners.