Skip to content

CSS Linear Gradient Generator

Free

Generate CSS linear-gradient() code visually. Set angle, add color stops, copy CSS instantly. Free, browser-based, no signup.

css linear gradient makerlinear gradient code generatorgradient background css
All Color Tools

Settings guide

Angle reference for linear-gradient:

AngleDirectionUse case
0degBottom to topUpward fade
45degBottom-left to top-rightDiagonal (square elements)
90degLeft to rightHorizontal transition
135degTop-left to bottom-rightDiagonal (opposite)
180degTop to bottomDownward fade (default)

Color stop positioning tips:

  • ·Place stops close together for sharp color bands: #FF5733 49%, #3B82F6 51%
  • ·Use repeated gradients for patterns: repeating-linear-gradient(45deg, #000 0px, #000 10px, #fff 10px, #fff 20px)
  • ·Stack gradients for vignette over image: linear-gradient(rgba(0,0,0,0.6), transparent 40%), url('image.jpg')

Browser support: All major browsers, no prefix needed since 2013. The -webkit- prefix is no longer required.

Format comparison

Linear vs radial gradient: Linear transitions along a line. Radial expands from a center point in a circle or ellipse. For most UI backgrounds and overlays, linear is the right choice. Radial gradients work well for spotlight effects, light source simulations, and circular glows.

Linear vs mesh gradients (CSS): True mesh gradients (smooth multi-directional transitions) are not supported in CSS. Work-arounds include overlapping multiple radial gradients or using an SVG. For single-direction gradients with multiple colors, linear-gradient handles it cleanly.

Performance: linear-gradient() is GPU-accelerated and has no performance overhead compared to solid background colors. Unlike background images, it requires no network request. It recalculates when the element resizes — which is GPU-cheap for most cases. Avoid animating gradient values directly (use opacity instead).

How it works

1

Set direction

Choose an angle (0–360°) or a direction keyword. 90° means left to right; 180° means top to bottom.

2

Add color stops

Place two or more color stops on the gradient bar. Drag to reposition. Set percentage positions for precise control.

3

Preview

See the gradient live in the preview panel — square, wide, and narrow aspect ratios.

4

Copy CSS

Copy the complete CSS value — ready to paste as a background or background-image property.

About this format

`linear-gradient()` is the most-used CSS gradient function — it creates a smooth color transition along a straight line at any angle. From subtle hero overlays to vibrant button backgrounds to dark reading masks over images, linear gradients are a foundational CSS technique that requires no image assets and renders at any resolution.

A linear gradient needs at minimum: a direction and two colors. The direction is an angle in degrees or a keyword like `to right`, `to bottom`, or `to bottom right`. Colors are specified at stop positions (0%, 50%, 100%) or distributed evenly if positions are omitted. You can add as many stops as needed.

The generated code is a single CSS `background` or `background-image` property value. It works as a standalone background, as an overlay on top of a background image, or as a fill on text using `background-clip: text`.

Frequently asked questions

What is the default direction of a CSS linear gradient?+
The default direction is 'to bottom' (180deg), meaning the gradient transitions from top to bottom. If you write linear-gradient(red, blue) without specifying a direction, it goes from red at the top to blue at the bottom.
How do I create a diagonal gradient?+
Use an angle: linear-gradient(45deg, #FF5733, #3B82F6) goes from bottom-left to top-right. For a gradient that adapts to the element's shape, use a corner keyword: linear-gradient(to bottom right, #FF5733, #3B82F6) — this adjusts the angle based on the element's width and height ratio.
Can I use HSL colors in a linear gradient?+
Yes. All valid CSS color values work in gradients: linear-gradient(to right, hsl(14, 100%, 60%), hsl(217, 91%, 60%)). You can mix formats — hex, hsl, rgb, and named colors can all appear in the same gradient.
How do I create a hard color stop (no transition)?+
Place two stops at the same position: linear-gradient(to right, red 50%, blue 50%). This creates a sharp boundary with no blending. You can create striped patterns this way: linear-gradient(to right, red 25%, blue 25%, blue 50%, red 50%).
Can I make a linear gradient on text?+
Yes. Apply the gradient as background: linear-gradient(to right, #FF5733, #3B82F6), then add -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text. This clips the gradient to the text shape. Works in all modern browsers; Safari requires the -webkit- prefixed properties.

Related tools and guides