Home Text Tools Math & Numbers Developer Tools Date & Time Image Tools Blog
CSS Gradient Generator

Design a Hero Section Background with a CSS Gradient

Build a smooth hero background with CSS gradients: choose angles and color stops, keep text readable, and avoid ugly banding.

The first screen of a landing page usually needs a background that feels designed without costing a heavy image download. A CSS gradient is a few lines of text, scales to any screen size and can be edited in seconds.

CSS Gradient Generator FREE online toolRuns in your browser. No sign-up, nothing to install. Open the tool

Pick the kind of gradient

A linear gradient moves along a line, and the angle sets the direction. 180deg runs top to bottom, 90deg runs left to right, and 135deg gives the common diagonal sweep. A radial gradient spreads from a center point and works well for a soft glow behind a product image or headline.

Two or three stops are usually enough. A gradient from one brand color to a darker shade of the same hue looks calm and professional. Gradients between very different hues, like orange to blue, can pass through a muddy grey in the middle.

Think about where the eye should land. A gradient that fades from a saturated color at one corner to a calmer shade near the text pulls attention toward the headline without any extra decoration. If the page also has a photo, let the gradient echo one of the photo's colors so the two feel connected.

Build it step by step

  1. Open the CSS Gradient Generator and choose linear for a banner or radial for a spotlight effect.
  2. Set the first and last color stops using your brand colors.
  3. Pick the direction option that puts the lighter area where your image or main visual will be.
  4. Add a third stop only if the middle looks flat.
  5. Copy the CSS and paste it into the background property of your hero container.
  6. Set a solid background-color fallback just above it for very old browsers.

Keep the text readable

Contrast matters more than the gradient. White text needs a dark enough area behind it, and dark text needs a light one. WCAG recommends a contrast ratio of at least 4.5:1 for normal body text, and 3:1 for large headings.

Test the lightest part of the gradient, not the average. If the text crosses a bright patch, move the headline, darken that stop, or add a subtle overlay.

  • Check contrast at both ends of the gradient.
  • Place text over the darker or calmer region.
  • Avoid putting small copy in the area where hues change fastest.
  • Test on a phone, where the crop changes which part of the gradient shows.

Common problems

Banding appears as visible stripes on large, low-contrast gradients. Using stops that are a bit further apart in lightness, or adding a faint pattern layer, reduces it. A full-height hero on a tall screen needs the gradient to hold up at 1000 pixels or more.

Mobile height is another trap. A background-attachment fixed hero often misbehaves on phones, so keep it scrolling normally and use min-height rather than a fixed pixel height.

Finally, resist stacking too many effects. A single clear gradient plus a well-chosen headline usually looks sharper than three layered gradients with a blur.

Performance is a quiet advantage. A gradient is a few dozen bytes of CSS, so it adds no image request and no layout shift while the page loads. A comparable photographic background can easily be hundreds of kilobytes, which matters on slow mobile connections where the hero is the first thing people wait for.

Try the free CSS Gradient Generator
Runs in your browser. No sign-up, nothing to install.

Comments (0)

No comments yet. Be the first to share a thought.