# CSS Gradient Generator

URL: https://hifreetools.com/developer/css-gradient-generator

> Build linear and radial CSS gradients with a visual editor. Pick a gradient type, set the angle, add as many color stops as you want, watch a live preview update in real time, and copy clean, ready-to-paste background CSS.

## Quick answer

A CSS gradient generator turns visual controls into a CSS background value such as background: linear-gradient(90deg, #ff0000 0%, #0000ff 100%);. You choose linear or radial, set an angle for linear gradients, and add color stops (a color plus a position from 0% to 100%). This tool renders a live preview and gives you copyable CSS that works in every modern browser.

Choose a gradient type (linear or radial). For a linear gradient, set the angle in degrees: 0deg points the gradient upward, 90deg points right, 180deg down, and 270deg left. Add two or more color stops, each with a hex color and a position percentage; stops are interpolated in order. The tool assembles the value as linear-gradient(ANGLEdeg, COLOR1 POS1%, COLOR2 POS2%, ...) or radial-gradient(circle, COLOR1 POS1%, ...), prefixes it with "background:", renders a live preview box using that exact value, and exposes the string for one-click copying. Everything runs in your browser; nothing is uploaded.

## Examples

- Red to blue, left to right: Type: linear, Angle: 90deg, Stops: #ff0000 at 0%, #0000ff at 100% → background: linear-gradient(90deg, #ff0000 0%, #0000ff 100%);
- Three-stop diagonal sunset: Type: linear, Angle: 45deg, Stops: #ff512f at 0%, #f09819 at 50%, #ff512f at 100% → background: linear-gradient(45deg, #ff512f 0%, #f09819 50%, #ff512f 100%);
- Radial white-to-black spotlight: Type: radial, Stops: #ffffff at 0%, #000000 at 100% → background: radial-gradient(circle, #ffffff 0%, #000000 100%);

## FAQ

**How do CSS gradient angles work?**
In the linear-gradient() function, the angle sets the direction the gradient progresses. 0deg points to the top, and the angle increases clockwise: 90deg points right, 180deg points down, and 270deg points left. So linear-gradient(90deg, ...) blends from left to right. CSS accepts negative and decimal angles like 45.5deg; this tool rounds the angle to a whole degree.

**What is the difference between linear and radial gradients?**
A linear gradient transitions colors along a straight line whose direction you set with an angle. A radial gradient transitions colors outward from a center point in concentric shapes (this tool uses circle), so the first stop is at the center and the last is at the edges. Radial gradients ignore the angle control.

**How many color stops can I add?**
You can add as many stops as you like; the tool starts with two and lets you add or remove stops with the buttons. A minimum of two stops is required to produce a gradient. Each stop has its own color and a position from 0% to 100% that controls where that color sits along the gradient.

**Does the generated gradient work in all browsers?**
Yes. Standard linear-gradient() and radial-gradient() syntax has been supported unprefixed in all modern browsers (Chrome, Firefox, Safari, and Edge) for years, so the copied CSS works without vendor prefixes. Only very old browsers such as Internet Explorer 9 and earlier would need extra handling.

**Can I use shorthand hex colors like #f00?**
Yes. The tool accepts both three-digit shorthand (#f00) and six-digit hex (#ff0000). Shorthand is expanded by the browser the same way, so #f00 and #ff0000 render identically. Invalid values that are not proper hex codes show an error message instead of producing broken CSS.

**Is my data sent anywhere?**
No. The entire generator runs in your browser using inline styles and JavaScript. Your colors, angles, and the generated CSS never leave your device and nothing is uploaded to a server.

**How do I make a gradient go from top to bottom?**
Set the gradient type to linear and the angle to 180deg, which points the gradient downward so the first stop appears at the top and the last at the bottom. Use 0deg for bottom-to-top, 90deg for left-to-right, and 270deg for right-to-left.


## Sources

- [MDN Web Docs: linear-gradient()](https://developer.mozilla.org/en-US/docs/Web/CSS/gradient/linear-gradient)
- [MDN Web Docs: radial-gradient()](https://developer.mozilla.org/en-US/docs/Web/CSS/gradient/radial-gradient)
- [W3C CSS Images Module Level 3](https://www.w3.org/TR/css-images-3/#gradients)

Runs in the browser; nothing is uploaded. Cite as: HIFreeTools, "CSS Gradient Generator", https://hifreetools.com/developer/css-gradient-generator
