CSS Gradient Generator
A gradient can give buttons, cards, hero sections and badges a polished look without any image file. This generator writes the CSS for you: pick a linear or radial gradient, choose two colors, set the angle when needed, and copy the resulting background declaration straight into your stylesheet.
How to build a gradient
-
1
Pick the gradient type
Linear for a straight transition along an angle, or radial to spread the colors outward from a center point.
-
2
Choose two colors
Enter any hex colors (for example #2563eb and #16a34a) in the two color fields.
-
3
Set the angle (linear only)
The angle in degrees: 0deg points upward, 90deg to the right, 180deg downward. Radial gradients ignore the angle.
-
4
Generate the CSS
The tool builds the `background:` declaration with your values.
-
5
Copy the code
Copy the single declaration line and paste it into your stylesheet, inside the rule for the element you want to style.
Linear gradients
background: linear-gradient(135deg, #2563eb, #16a34a);
The angle runs clockwise from the top: 0deg = up, 90deg = right, 180deg = down, 270deg = left. You can also write named directions by hand: to right equals 90deg and to bottom left equals 135deg.
Radial gradients
background: radial-gradient(circle, #2563eb, #16a34a);
The colors spread outward from the center of the element. Radial gradients do not use an angle; add position or size keywords by hand (at 30% 40%, ellipse) when you need more control.
Color stops
CSS gradients accept more than two colors, and each stop can take a position:
background: linear-gradient(to right, red 0%, red 50%, blue 50%, blue 100%);
Two stops with the same position create a hard stop: the color changes instantly instead of blending. Useful for split backgrounds.
Tips
- A red to blue gradient passes through a greyish midpoint in the default sRGB interpolation. Interpolating in
oklchkeeps the blend colorful:linear-gradient(in oklch, red, blue), supported by modern browsers. transparentis not colorless: in sRGB it isrgba(0,0,0,0), so a fade to transparent passes through dark grey. Usergba(color, 0)instead.- Gradients render on the GPU in modern browsers, so they cost almost nothing at any size. Animating between gradients is not supported and snaps abruptly; animate the opacity of an extra layer instead.
- Text fills: combine the declaration with
background-clip: text; color: transparent;to fill text with a gradient. For borders,border-image: linear-gradient(...) 1;works in modern browsers.
Frequently Asked Questions
Linear for directional blends, such as a button or a hero that flows from top to bottom or corner to corner. Radial for spotlight and glow effects, where the colors spread outward from a center point.
The angle sets the direction of the transition for linear gradients: 0deg points upward, 90deg to the right, and so on clockwise. Radial gradients ignore the angle.
The default sRGB interpolation averages the color components, which produces a desaturated midpoint. Interpolate in oklch instead (linear-gradient(in oklch, red, blue)) to keep the blend colorful through the middle.
CSS cannot interpolate between two background-image values, the swap is abrupt. Common workarounds: animate the opacity of an overlay gradient, or shift background-position on a larger fixed gradient.
Related Tools
ASCII Table Reference
Full ASCII table from 0 to 127 with decimal, hex, octal, binary, standard names and HTML numeric-reference notation, including NUL, LF and DEL.
HEX Color Picker
Pick or enter a HEX colour and get RGB, HSL, approximate CMYK, relative luminance and contrast ratios against white and black.
Color Palette Generator
Generate monochromatic, analogous, complementary, triadic or tetradic color palettes from a base HEX color and export copy-ready CSS variables.
HTML Character Reference
Searchable list of HTML entities, their named and numeric codes, and a one-click copy for special characters and symbols.
FPS Counter
Measure browser FPS with requestAnimationFrame, smoothing, min/max frame rate, warnings and an optional graph. Runs locally with no upload or API.
JSON Formatter
Paste JSON to pretty-print with 2 or 4 spaces, minify it to compact output, or run a quick syntax check before copying the result.