liveBook · Manning

Radial-gradient function

As explained in CSS in Depth, Second Edition

The radial-gradient() CSS image function creates a radial gradient with specified colors, shape, size, position, and color space.

The radial-gradient() CSS image function creates a gradient that starts at one point and spreads outward in every direction. By default, it is centered, elliptical, and extends evenly to the element’s corners. section 13.1.3

A basic radial gradient

Apply the function as a background image: .fade { height: 200px; width: 400px; background-image: radial-gradient(white, blue); } The colors transition outward from the center, with the ellipse following the element’s proportions. section 13.1.3

Adjust the gradient when the default shape or position does not fit the design:

  • Add circle to create a circular gradient instead of an ellipse. section 13.1.3
  • Provide one size value for a circle, or two values for horizontal and vertical dimensions, such as radial-gradient(50px 25px, white, blue). section 13.1.3
  • Use at with x- and y-coordinates to move the gradient’s center, and define color-stop positions with percentages or lengths. section 13.1.3
  • Use repeating-radial-gradient() to repeat the colors in concentric rings. section 13.1.3

A radial gradient can also serve as a mask image. Transparent regions mask out the element, enabling effects such as a vignette; temporarily viewing the same gradient as a background can help diagnose an invisible mask. section 14.2.1

How CSS in Depth, Second Edition covers it

How deep it goes
Explains defaults, color stops, color space, shape, size, position, repetition, and masking, with examples rather than browser internals.
Examples
Uses a white-to-blue element background, visual gradient variants, concentric rings, and a radial vignette mask.
What it assumes
Assumes familiarity with CSS background images and color gradients while demonstrating the function through basic examples.
What you can do after
Apply it via CSS to build radial backgrounds, repeated rings, positioned highlights, and gradient-based masks.
How it connects
Connects radial gradients with linear gradients, conical gradients, color interpolation, background images, repeating gradients, and masks.

Also explained in

Compare how 2 books explain radial-gradient function →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of CSS in Depth, Second Edition. The section links point to the parts of the book it draws on.