Radial gradients in CSS are a powerful tool for creating visually appealing backgrounds. They allow you to create a smooth transition from one color to another, radiating out from a central point. This can be used to create a variety of effects, from simple color transitions to complex, multi-colored gradients. In this article, we'll explore how to create and customize radial gradients in CSS.
Understanding Radial Gradients
Before we dive into the code, let's understand what radial gradients are. A radial gradient is a type of gradient where the colors radiate out from a central point, creating a circular or elliptical effect. This is different from linear gradients, where the colors transition along a straight line.
Syntax
The syntax for a radial gradient is as follows:

background: radial-gradient([shape] size at [position], color-stop1, color-stop2, ...);
The shape property determines the shape of the gradient. It can be either ellipse or circle. The size property determines the size of the gradient. It can be a length value, a percentage, or the keywords closest-side, farthest-side, closest-corner, or farthest-corner. The position property determines the center of the gradient. It can be a length value or a percentage. Finally, the color-stop properties determine the colors of the gradient.
Creating a Simple Radial Gradient
Let's start by creating a simple radial gradient. We'll create a gradient that transitions from blue to red, radiating out from the center of the element.
background: radial-gradient(circle, blue, red);
In this example, we've set the shape to circle, which means the gradient will be circular. The colors of the gradient are blue and red. The gradient will start at the center of the element and radiate outwards, creating a circular effect.

Customizing the Radial Gradient
Now that we've created a simple radial gradient, let's explore some of the ways we can customize it.
Changing the Shape
We can change the shape of the gradient by using the ellipse value for the shape property. This will create an elliptical gradient instead of a circular one.
background: radial-gradient(ellipse, blue, red);
Changing the Size
The size property allows us to change the size of the gradient. We can use a length value, a percentage, or one of the keywords to determine the size.

For example, let's create a gradient that is 200px in diameter:
background: radial-gradient(circle, blue, red) 100px 100px / 200px 200px;
In this example, we've set the size to 100px 100px, which means the gradient will be 100px wide and 100px tall. The / 200px 200px part determines the size of the gradient in relation to the element. In this case, the gradient will be 200px in diameter, regardless of the size of the element.
Changing the Position
The position property allows us to change the center of the gradient. We can use a length value or a percentage to determine the position.
For example, let's create a gradient that radiates out from the top left corner of the element:
background: radial-gradient(circle, blue, red) 0 0;
Adding More Color Stops
We can add more color stops to the gradient to create more complex effects. Each color stop consists of a color and a position, which determines where the color starts to appear in the gradient.
For example, let's create a gradient that transitions from blue to green to red:
background: radial-gradient(circle, blue 0%, green 50%, red 100%);
Browser Support
Radial gradients are supported in all modern browsers, including Chrome, Firefox, Safari, and Edge. However, they are not supported in Internet Explorer. You can use a tool like Can I Use to check the browser support for radial gradients.
Conclusion
Radial gradients are a powerful tool for creating visually appealing backgrounds in CSS. They allow us to create a variety of effects, from simple color transitions to complex, multi-colored gradients. By understanding the syntax and customization options for radial gradients, we can create unique and engaging designs for our websites and applications.






















