Gradients went from a design trend to a permanent tool — every button, hero section, and dashboard uses them. Writing the CSS by hand is fiddly; understanding it is simple.
The two types you’ll actually use
background: linear-gradient(90deg, #4f46e5, #22d3ee);
A linear gradient blends colors along a straight line. The angle (or direction like to right) decides the axis; each color stop is a point along that line.
Radial gradients blend outward from a center point — useful for spotlight effects and soft glows. Everything else (conic, repeating) is niche.
The most common mistake: too many color stops. Two or three colors look deliberate; five look like a 1990s screensaver.
Generating the code
- Open the CSS gradient generator.
- Pick a direction and two or three colors.
- Copy the
backgroundline straight into your stylesheet.
The generator outputs standard CSS, so it works in any framework. For production, minify the result together with your other styles using the CSS minifier to trim file size.
The details that bite
- Angle order:
90deggoes left-to-right;0deggoes bottom-to-top. If your gradient looks rotated, the angle is the first suspect. - Color stops with positions:
#fff 0%, #000 100%sets explicit stops; you can also write#fff, #000and let the browser space them evenly. - Fallbacks: very old browsers ignore gradients entirely — always keep a plain
background-colordeclared first, and the gradient will override it where supported.
Gradients are background garnish. Generate, paste, and move on to the content.