CSS Repeating Linear Gradient Background

A repeating linear gradient in pure CSS: light, mid and deep purple bands that blend and repeat forever. Set the band width and angle, then copy the code.

#880088
#b560b5
#6f006f
45deg
120px
.bg-repeating-gradient {
  --bg: #880088;
  --c1: #b560b5;
  --c2: #6f006f;
  --angle: 45deg;
  --size: 120px;
  background-color: var(--bg);
  background-image: repeating-linear-gradient(var(--angle), var(--bg) 0, var(--c1) calc(var(--size) / 3), var(--c2) calc(var(--size) * 2 / 3), var(--bg) var(--size));
}
<div class="
  [--bg:#880088]
  [--c1:#b560b5]
  [--c2:#6f006f]
  [--angle:45deg]
  [--size:120px]
  [background-color:var(--bg)]
  [background-image:repeating-linear-gradient(var(--angle),_var(--bg)_0,_var(--c1)_calc(var(--size)_/_3),_var(--c2)_calc(var(--size)_*_2_/_3),_var(--bg)_var(--size))]
"></div>
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Repeating Gradient — CSS background</title>
  <style>
    html, body { height: 100%; margin: 0; }
    .bg-repeating-gradient {
      --bg: #880088;
      --c1: #b560b5;
      --c2: #6f006f;
      --angle: 45deg;
      --size: 120px;
      background-color: var(--bg);
      background-image: repeating-linear-gradient(var(--angle), var(--bg) 0, var(--c1) calc(var(--size) / 3), var(--c2) calc(var(--size) * 2 / 3), var(--bg) var(--size));
    }
  </style>
</head>
<body class="bg-repeating-gradient"></body>
</html>

Save the pattern as an image, with your current colors and settings.

How this repeating gradient works

repeating-linear-gradient() works like a normal linear gradient, except it repeats its stops forever. Here the stops run purple at 0, light purple at a third of --size, deep purple at two thirds and purple again at --size. All three are shades of one palette color. CSS then repeats that run every --size pixels.

Ending on the same color you started with is what makes it seamless. Each repeat begins with the color the last one ended on, so there’s no hard line between them, just smooth, rolling bands.

--size sets the width of one full cycle. Small values give fine ribbons, large ones slow waves of color. --angle turns the bands: 45deg runs them diagonally, 90deg makes vertical bands and 0deg horizontal ones.

For hard-edged stripes instead of soft bands, repeat each color’s position, like var(--bg) 0 20px, var(--c1) 20px 40px. That’s how the stripe patterns on this site are built.

Use it for bold hero backgrounds, retro and psychedelic themes, and section dividers.

All CSS background gradients →