A flat background color is safe and forgettable. A gradient gives a hero section or a page backdrop depth without an image file, without a download hit, and without a designer. The catch is that hand-writing gradient syntax from memory is fiddly: one wrong angle or a stop in the wrong order and the result looks nothing like the picture in your head.
This guide explains how CSS gradients are put together and how to build one visually with the free CSS Gradient Generator on Ovatly, which shows a live preview and hands you a single production-ready background declaration to copy.
Contents
- Quick answer
- The three gradient types
- Direction: what the angle actually controls
- Color stops: the part that does the work
- How to create a gradient, step by step
- Worked example: a diagonal blue background
- Limitations and honest tradeoffs
- Common mistakes
- FAQs
- Conclusion
- References
Quick answer
Open the CSS Gradient Generator, choose a type (linear for most backgrounds), set the angle, then adjust each color stop's color and position, adding or removing stops as needed. The preview updates with every change. When it looks right, copy the single background declaration from the output and paste it into your stylesheet. Stops are emitted as hex colors and sorted by position, so the code you copy is exactly the gradient you see.
The three gradient types
Linear gradients run in a straight line from one side to the other, steered by an angle. This is the workhorse for page backgrounds and hero sections, because a gentle shift from one color to a relative of it reads as light and depth rather than decoration.
Radial gradients spread outward from a center point, shaped by the radial shape you set. They suit spotlight effects and soft glows behind a headline, where the lightest or darkest point should sit in the middle and fade toward the edges.
Conic gradients sweep colors around a center point like the hands of a clock. Pie charts, color wheels, sunburst effects and angular highlights are their natural territory. For a plain website background they are usually too busy, but they are the right tool when the design is built around a center.
Direction: what the angle actually controls
For a linear gradient, the angle sets the direction the gradient travels. The three values worth memorising cover most layouts: 180deg points downward, so the start color sits at the top and the end color at the bottom; 90deg runs left to right; 0deg runs bottom to top, the exact reverse of 180deg. Diagonal angles such as 135deg split the difference and are popular for hero backgrounds because the eye reads them as light falling across the page.
Radial and conic gradients are not steered by this angle in the same way. A radial gradient is controlled by its shape and center, and a conic gradient sweeps around its center, so the generator swaps the angle control for the radial shape setting when you change type.
Color stops: the part that does the work
A color stop is a color pinned to a position along the gradient, written as a percentage. The browser blends smoothly between neighboring stops, so a stop at 0% and another at 100% produce a full-range blend, while moving a stop to 60% stretches the first color across more of the background and compresses the blend into the remaining space.
The generator supports up to six stops, each with its own color and position, and you can add or remove them freely. Two habits keep stops under control. First, the output sorts stops by position even if you set them out of order, matching how CSS resolves them, so the declaration you copy is always in running order. Second, placing two stops at exactly the same position is not an error: it creates a hard edge, an instant color change instead of a blend, which designers use deliberately for stripes and sharp splits.
Colors are emitted as hex values, for example #0ea5e9. Every stop is a solid color, a point the limitations section returns to.
How to create a gradient, step by step
- Open the CSS Gradient Generator and choose the gradient type: linear, radial or conic.
- Set the angle, or the radial shape if you picked radial.
- Adjust the first stop's color and position, then the last stop's. Get the two endpoints right before adding anything in the middle.
- Add a stop only when the blend needs a mid-tone or a distinct band, and set its position deliberately rather than accepting the middle by default.
- Copy the
backgrounddeclaration from the output box and paste it into the CSS rule for your page, section or element. Check it at full width in the browser, because a gradient that looks rich in a small preview can look stretched on a wide screen.
Worked example: a diagonal blue background
Set the type to linear and the angle to 135deg. Give the first stop the color #0ea5e9 at 0% and the second stop #2563eb at 100%. The generator produces:
background: linear-gradient(135deg, #0ea5e9 0%, #2563eb 100%);
That one line is the complete background. The lighter sky blue starts at the top-left corner and deepens toward the richer blue at the bottom-right, because 135deg aims the gradient diagonally down and to the right. Nothing else is required: no image, no prefix, no extra properties. If the blend feels too strong at full width, the fix is in the stops, not the syntax: move the second stop's color closer to the first, or add a mid stop to soften the transition.
Limitations and honest tradeoffs
The honest limit is transparency. Stops are solid hex colors, and this generator does not emit a fade to transparent. Designs that need a photo to show through a fading overlay gradient need hand-written CSS with a color format that carries an alpha channel, and no amount of stop-shuffling here will substitute.
The preview is a live CSS rendering, not an image file. There is no PNG or JPG to download, which is normally a strength (the background scales to any screen and weighs nothing), but it means a gradient cannot be lifted out of the browser for use in a context that does not accept CSS. Six stops is also a real ceiling: plenty for backgrounds, too few for a photorealistic multi-band illustration, which is a job for an image anyway.
Common mistakes
- Too much contrast between stops. A background that fights the text on top of it has failed at its job. Keep endpoint colors in the same family unless the design deliberately wants drama.
- Judging the gradient in the small preview only. Always check at the real display size. Blends stretch over wide screens and subtle shifts can vanish or turn muddy.
- Adding stops to fix a blend that positioning should fix. A harsh transition usually means a stop sits in the wrong place, not that another color is missing.
- Expecting a transparent fade. The output is solid hex. If the design needs transparency, plan to hand-write that gradient instead of discovering the limit at deadline time.
- Reaching for an image export. There is none, by design. The deliverable is the declaration itself.
FAQs
What angle makes a linear gradient run from top to bottom? 180deg. At 180deg the gradient points downward, so the first color sits at the top and the last color at the bottom. 90deg runs left to right, and 0deg runs bottom to top, the reverse of 180deg.
How many color stops can a gradient have? The generator supports up to six stops. Each stop has a color and a position, and you can add or remove stops as the design needs. Two stops are enough for most backgrounds; extra stops earn their place when you need a mid-tone or a band of color.
Can I make a gradient that fades to transparent? Not with this generator. Its stops are solid hex colors, and hex output has no transparency channel, so a fade to transparent is not something it emits. If a design truly needs a transparent fade, that gradient has to be written by hand with rgba or hsla colors.
Do I need vendor prefixes for gradients? No. The generated code is a single standard background declaration, and vendor prefixes are unnecessary in current browsers. Paste it into your stylesheet as it comes out.
Can I download the gradient as an image? No. The preview is a live CSS rendering, not an image file, and there is nothing to download. Copy the background declaration and use it in your CSS, which also keeps the background resolution-independent and tiny compared with an image.
Conclusion
A good background gradient is three decisions: the type, the direction, and stops placed where the blend needs them. The CSS Gradient Generator turns those decisions into one clean declaration you can paste straight into a stylesheet. The security side of shipping that page has its own inspection job, covered in our companion guide on decoding an SSL certificate and reading its details. For more guides in this series, see our Website and Webmaster Tools guides.
References
- MDN Web Docs, on the linear-gradient() function and gradient syntax: https://developer.mozilla.org/en-US/docs/Web/CSS/gradient/linear-gradient
- MDN Web Docs, on using CSS gradients in backgrounds: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_images/Using_CSS_gradients