Saved

Press the star next to a tool's name to save it.

All my tools

CSS Gradient Generator

Use this CSS gradient generator to create linear, radial and conic gradients from your own colour stops, preview them live and copy the CSS. It runs in your browser.

Write each stop as a colour followed by an optional position, such as #ff7e5f 0% or red 25%. Hex, rgb(), hsl() and CSS names work. Use at least two stops. Stops without a position are spaced evenly.

Preview and CSS

Add at least two colour stops to see the gradient.

This CSS gradient generator builds linear, radial and conic gradients from your own colour stops and shows a live preview as you edit. Choose the type, set the angle or centre, list your colours, and copy the finished background rule straight into your style sheet. A repeating option makes stripes and rings, and everything runs in your browser, so nothing you type is uploaded.

How to use the CSS gradient generator

  1. Pick Linear, Radial or Conic.
  2. Set the angle for linear and conic gradients, or the shape and centre for radial ones.
  3. Type your colour stops, one per line, with an optional position such as 40% or 120px.
  4. Tick Repeating if you want the pattern to tile.
  5. Copy the CSS and paste it into your rule.

Linear gradients

A linear gradient blends colours along a straight line. An angle of 0deg points to the top and increasing values rotate clockwise, so 90deg points right and 180deg points down. Keywords such as to right are shorthand for those angles, and if you give no direction the default is to bottom. [1] This tool always writes the direction as an angle, so the result is easy to adjust.

Radial gradients

A radial gradient spreads colour outward from a centre point. Its shape is either a circle with a constant radius or an ellipse, which is the default, and its size defaults to the farthest corner. The centre works like a background position and defaults to the middle. [2] The generator offers circle or ellipse and nine centre positions, and keeps the default size.

Conic gradients

A conic gradient sweeps colour around a centre point, like the face of a clock. By default it starts at north, and the from angle rotates the start clockwise. Percentages in a conic gradient refer to the full circle, so 100% equals 360 degrees. [3] Hard-edged stops at the same position make pie-chart style slices.

Colour stops and positions

A colour stop is a colour with one or two optional positions. The first stop defaults to 0% and the last to 100%, and any run of unpositioned stops between them is spaced evenly. [4] Giving a colour two positions on one line, such as orange 20% 40%, makes a solid band between them, and giving two adjacent stops the same position makes a hard edge. [1]

Stops you typeWhat you get
#ff7e5f 0%, #feb47b 100%A smooth blend from coral to peach
red, yellow, greenThree colours spaced evenly
red 50%, blue 50%A hard edge in the middle
red 20% 40%, blue 60%A solid red band, then a blend to blue

Repeating gradients

The repeating versions take the same arguments but tile the stop list to fill the element. [1] For a pattern to repeat visibly, the last stop must be smaller than the element, so give positions in pixels or small percentages. For example, red 0px, blue 20px repeated at 45 degrees makes diagonal stripes. Without positions, a repeating gradient looks the same as an ordinary one.

CSS gradient generator examples

  • Sunset: linear at 135deg with #ff7e5f 0% and #feb47b 100%.
  • Spotlight: radial circle at the centre from white to transparent black.
  • Colour wheel: conic from 0deg with red, yellow, lime, cyan, blue, magenta and red.
  • Stripes: repeating linear at 45deg with stops such as #222 0px and #444 10px.

Using the CSS

Paste the background rule into any selector. Gradients are images, so they work with background and background-image, and you can layer several by separating them with commas. Add a plain fallback colour on the line above for older software. If text sits on the gradient, check its contrast against the lightest and darkest stops.

Choosing colours that work together

Smooth gradients usually come from colours that are close in hue, such as coral to peach or deep blue to teal. Colours far apart on the wheel can pass through a muddy grey in the middle, so add a bridging stop if the blend looks dull. Keep the lightness change gentle if text will sit on top, and test the result on both light and dark screens. Transparent stops are handy for fades: a stop written as rgb(0 0 0 / 0%) lets the page show through.

Colours and positions accepted

Each stop can use a hex code with three, four, six or eight digits, an rgb(), hsl() or hwb() function, or a CSS colour name. Positions can be percentages or lengths such as 30px or 2em, and conic gradients also accept angles like 90deg or turns. The generator checks every line before it builds the rule, so a typo shows a clear message instead of broken CSS.

Preview limits

The preview is a 200 pixel high box that shows the gradient exactly as your browser draws it. Real elements have other shapes, so a radial gradient may look different on a tall sidebar than in the preview. Copy the CSS, apply it to your element and adjust the position or shape there if needed.

Common mistakes

  • Mixing up angle directions. 0deg is up, not right.
  • Using one stop. A gradient needs two or more.
  • Expecting stripes without positions. Hard edges need two stops at the same position.
  • Putting commas inside a stop line. Write one stop per line; commas only appear inside functions such as rgb(0, 0, 0).

Privacy

The preview and the CSS are made on your device. Your colours are not sent anywhere.

What next

Use this often? Add CSS Gradient to your Home screen.

Frequently asked questions

What is a CSS gradient generator?

A CSS gradient generator builds the code for a gradient background from your colours and settings and shows a preview, so you can copy ready-made CSS.

What is the difference between linear, radial and conic gradients?

Linear gradients blend along a straight line, radial gradients spread from a centre point in a circle or ellipse, and conic gradients sweep around a centre like a clock face.

How do I make a hard edge in a gradient?

Give two neighbouring colour stops the same position, for example red 50% and blue 50%. The colour changes sharply at that point.

Which angle points to the right?

In CSS, 0deg points up and angles turn clockwise, so 90deg points right, 180deg points down and 270deg points left.

Is anything uploaded?

No. The gradient is generated and previewed in your browser.

What went wrong?

We only receive the reason you pick, never what you typed into the tool.

Thanks for your feedback.

More Developer Tools