How to Create CSS Gradients for Websites
A practical guide to creating linear, radial, and conic CSS gradients with clear color stops, readable content, and production-ready CSS.
CSS gradients are useful when they support a layout, establish a focal point, or make a brand color feel more dimensional. They become difficult to use when they replace hierarchy, hide important text, or add color simply because a flat background feels unfinished.
The practical way to create a CSS gradient is to start with a clear surface role, use only the color stops it needs, then test the result with real content. The free Gradient Generator lets you build linear, radial, and conic gradients with exact stop positions and copy the CSS when the direction is ready.
What is a CSS gradient?
A CSS gradient is an image created by the browser from a sequence of colors. Instead of loading a bitmap image, CSS calculates the transition between color stops at render time.
The three most useful types are:
| Type | What it does | Best use |
|---|---|---|
| Linear | Moves colors along a straight line | Hero sections, banners, buttons, image overlays |
| Radial | Expands colors from a point | Soft spotlights, ambient backgrounds, illustrations |
| Conic | Sweeps colors around a center | Decorative rings, charts, color-wheel-like visuals |
For most website sections, start with a linear gradient. It is predictable, easy to position around content, and works cleanly with the rectangular shapes used in pages and components.
Start with a job for the gradient
Before choosing colors, decide what the gradient is meant to do. A useful gradient usually has one of these jobs:
- Add depth to a hero or campaign section
- Guide attention toward a headline, product image, or call to action
- Create a quiet ambient surface behind a card or illustration
- Connect two brand colors in a large visual area
- Give a chart, ring, or decorative detail a controlled color transition
Avoid using a gradient as the default background for every card, button, and section. When gradients appear everywhere, actions lose emphasis and a page becomes harder to scan.
Choose two or three color stops first
Two stops are enough for a simple transition. Three stops let you create a deliberate middle point, such as a brand color moving through a softer support tone before reaching an accent.
Start with this website-friendly direction:
- Deep indigo:
#312E81 - Brand indigo:
#4F46E5 - Warm orange:
#F97316
#312E81
Deep indigo
#4F46E5
Brand indigo
#F97316
Warm orange
Open this editable three-stop gradient to see how the stops and angle work together.
Use a fourth or fifth stop only when it changes the composition intentionally. For example, an extra stop can give a brand color more space near a headline, or make a transition feel slower before it reaches a bright accent. Adding stops only because a gradient looks too simple usually makes it harder to reuse.
If you need calculated in-between colors from exactly two endpoints, use the Color Mixer. It produces a color scale. Once you know which of those colors belong in the composition, use the Gradient Generator to place them precisely.
Create a linear gradient
Linear gradients work by placing color stops along an angle. In CSS, 0deg points upward, 90deg points right, 180deg points down, and 270deg points left.
.hero {
background: linear-gradient(120deg, #312E81 0%, #4F46E5 48%, #F97316 100%);
}
An angle around 120deg or 135deg often feels natural for a left-aligned desktop hero because the transition moves diagonally across a wide area. This is not a rule: flip the direction when it moves the brighter color behind important copy or creates visual weight on the wrong side of the layout.
For a simple section background, keep the color stops at 0% and 100%. Move an intermediate stop only when it needs to occupy more or less space. A middle stop at 20% makes the first color change quickly; a stop at 75% lets the first colors stay visible for longer.
Use radial and conic gradients with a clear focal point
A radial gradient starts at a chosen center point and expands outward. It is useful when a design needs a soft glow behind an illustration, avatar, product image, or card.
.feature-panel {
background: radial-gradient(circle at 35% 30%, #A7F3D0 0%, #14B8A6 42%, #312E81 100%);
}
Move the center away from dense text. A glow should support the focal point, not sit exactly behind a paragraph or form field.
Conic gradients rotate around a center. They are powerful for compact decorative details, but can overwhelm a full page background. Use them for a progress ring, a small visual marker, or an intentional color-wheel treatment—not because they are more complex than a linear gradient.
.status-ring {
background: conic-gradient(from 30deg at 50% 50%, #F97316 0%, #FACC15 31%, #22C55E 64%, #F97316 100%);
}
Keep text readable on gradients
Text contrast on a gradient is harder than contrast on a solid background because the background changes across the element. A white heading can be readable over the dark edge of a gradient and disappear over the light edge.
Use one of these safer patterns:
- Put important copy inside a solid card or panel
- Use a translucent overlay behind text, then test it at the final opacity
- Position text over the most stable, darkest or lightest part of the gradient
- Add the gradient to a decorative layer behind the actual content surface
- Keep body copy off decorative gradients entirely
Do not approve text after testing only one point in the background. Check it against every color region it overlaps. The Contrast Checker is useful for testing the individual foreground-and-stop pairs, while the Website Color Preview helps you assess hierarchy, cards, CTAs, and body copy together.
Turn gradient colors into a usable website system
A gradient can be expressive, but a website still needs clear role colors for the page background, text, primary action, secondary surface, and accent. Do not make the gradient the source of every UI decision.
After choosing a direction, take its stops into the Palette Generator to build a fuller color system. Then map the resulting roles into Website Color Preview before adding them to CSS variables or a design system.
This matters most when a gradient contains a bright accent. That color may work beautifully at the edge of a hero but be too intense for buttons, text links, or selected navigation. Treat the gradient as one surface treatment, not a replacement for semantic design tokens.
Common CSS gradient mistakes
Using too many saturated colors
Several bright hues can look exciting in a thumbnail but distract from content at full page size. Start with one or two related colors and add contrast through lightness before adding more hue changes.
Placing the brightest area behind the call to action
Calls to action need a clear boundary. If the brightest point of the gradient sits behind the button, the button can lose contrast or feel visually noisy. Move the stop, reverse the angle, or put the action on a solid surface.
Copying a gradient without testing it in the component
The same gradient can look restrained in a wide banner and harsh in a short card. Test it at the real component size, with the final text length, imagery, borders, and responsive layout.
Treating a gradient as an accessibility result
There is no single contrast ratio for a multicolor surface. Test each relevant region and do not rely on hue alone to communicate status, priority, or selection.
A practical CSS gradient checklist
Before shipping a gradient, confirm that:
- The gradient has a specific visual job
- Two or three stops communicate the intended transition
- Extra stops exist for a clear compositional reason
- The chosen type and angle support the component shape
- Important text and actions have a stable readable surface
- Bright accents do not compete with the primary action
- The CSS has been tested at real desktop and mobile sizes
- The colors also work as a broader palette outside the gradient
Use the Gradient Generator to build and share an editable version, then run the colors through the rest of the system before treating the gradient as production-ready.
FAQ
What is the easiest way to create a CSS gradient?
Start with a visual gradient generator, choose a linear, radial, or conic type, set two or three color stops, then copy the CSS declaration. This gives you exact values while keeping the design process visual.
What is the difference between linear, radial, and conic gradients?
A linear gradient moves in a straight direction, a radial gradient expands from a center point, and a conic gradient rotates around a center point. Linear gradients are the most common option for website backgrounds.
How many colors should a CSS gradient use?
Two or three stops are enough for most website gradients. Add a fourth or fifth stop only when it creates a deliberate transition or focal point; too many stops can make an interface look noisy.
Can white text go on a gradient background?
Sometimes, but it must remain readable against every part of the gradient behind it. A safer approach is to place essential copy on a solid or translucent overlay and test individual color pairs with a contrast checker.
Related color guides
Continue with practical color palette guides from Colortion.
From guide to color system
Create a Palette for Your Next Design
Use the generator to build a 5-color palette, copy hex codes, and test combinations before adding them to your project.