CSS Diagonal Stripes Background

Diagonal stripes in pure CSS using one repeating-linear-gradient. Set the stripe width, angle and colors with custom properties, then copy CSS or Tailwind.

#f09f33
#f6c380
16px
45deg
.bg-diagonal-stripes {
  --bg: #f09f33;
  --fg: #f6c380;
  --size: 16px;
  --angle: 45deg;
  background-color: var(--bg);
  background-image: repeating-linear-gradient(var(--angle), var(--fg) 0 var(--size), transparent 0 calc(var(--size) * 2));
}
<div class="
  [--bg:#f09f33]
  [--fg:#f6c380]
  [--size:16px]
  [--angle:45deg]
  [background-color:var(--bg)]
  [background-image:repeating-linear-gradient(var(--angle),_var(--fg)_0_var(--size),_transparent_0_calc(var(--size)_*_2))]
"></div>
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Diagonal Stripes — CSS background</title>
  <style>
    html, body { height: 100%; margin: 0; }
    .bg-diagonal-stripes {
      --bg: #f09f33;
      --fg: #f6c380;
      --size: 16px;
      --angle: 45deg;
      background-color: var(--bg);
      background-image: repeating-linear-gradient(var(--angle), var(--fg) 0 var(--size), transparent 0 calc(var(--size) * 2));
    }
  </style>
</head>
<body class="bg-diagonal-stripes"></body>
</html>

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

Diagonal Stripes in other colors

Click a color to try it in the preview above, then copy the code.

Browse by color: Red · Orange · Yellow · Green · Teal · Blue · Purple · Pink

How the diagonal stripes pattern works

This pattern uses a single repeating-linear-gradient(). The gradient runs along --angle and repeats one band of two stripes: --fg from 0 to --size, then transparent from there to twice --size, so the background color shows through.

Writing transparent 0 makes the second color stop start exactly where the first one ends. Two stops at the same position create a hard edge instead of a blend.

Because the gradient repeats itself, there’s no background-size and no tile, so the stripes never show seams at any angle.

Change --size for thicker or thinner stripes and --angle to tilt them: 45deg slants up to the right, 135deg slants the other way, and 90deg gives vertical stripes. For caution-tape styling, use a yellow --bg with a near-black --fg. For a subtle card background, pick two colors that are close in lightness.