Skip to main content

CSS radial-gradient() Function

Use the CSS radial-gradient() function to produce a radial gradient: colors that blend outward from a central point.

At least two color stops are required. These are the colors the gradient moves smoothly between.

Syntax

Defaults: ellipse for the shape, farthest-corner for the size, and center for the position.

styles.css
background-image: radial-gradient(shape size at position, start-color, ..., last-color);

Radial Gradient - Evenly Spaced Color Stops (this is default)

Here the color stops are evenly spaced, which is what a radial gradient does by default:

Example

Prompt
Create a page with a div that has a radial gradient background using three evenly spaced color stops: red, yellow, and green.
Output: complete HTML page

Radial Gradient - Differently Spaced Color Stops

In this radial gradient, each color stop has a different spacing:

Example

Prompt
Create a page with a div that has a radial gradient background with differently spaced color stops: red at 5%, yellow at 15%, and green at 60%.
Output: complete HTML page

Radial Gradient - Set Shape

Two values are available for the shape parameter, which controls the gradient's shape:

  • ellipse (the default)
  • circle

Example

Here the radial gradient takes the shape of a circle:

Prompt
Create a page with a div that has a radial gradient background shaped as a circle, with color stops red, yellow, and green.
Output: complete HTML page

Radial Gradient - The size Parameter

How big the gradient's ending shape gets depends on the size parameter, which accepts these values:

  • closest-side
  • farthest-side
  • closest-corner
  • farthest-corner (the default)

Example

Different size keywords produce different radial gradients:

Prompt
Create a page with two divs showing radial gradients with different size keywords: one using closest-side and one using farthest-side, both positioned at 70% 60%, with colors red, yellow, and black.
Output: complete HTML page

CSS repeating-radial-gradient() Function

To make a radial gradient repeat, reach for the CSS repeating-radial-gradient() function:

Example

A radial gradient that repeats:

Prompt
Create a page with a div that has a repeating radial gradient background with color stops: red, yellow at 10%, and green at 15%.
Output: complete HTML page