CSS Zigzag Background

A zigzag (chevron) background in pure CSS made from four angled linear gradients. Change the zigzag size and colors live, then copy the CSS or Tailwind classes.

#f09f33
#f6c380
40px
.bg-zigzag {
  --bg: #f09f33;
  --fg: #f6c380;
  --size: 40px;
  background-color: var(--bg);
  background-image:
    linear-gradient(135deg, var(--fg) 25%, transparent 25%),
    linear-gradient(225deg, var(--fg) 25%, transparent 25%),
    linear-gradient(315deg, var(--fg) 25%, transparent 25%),
    linear-gradient(45deg, var(--fg) 25%, transparent 25%);
  background-position: calc(var(--size) / -2) 0, calc(var(--size) / -2) 0, 0 0, 0 0;
  background-size: var(--size) var(--size);
}
<div class="
  [--bg:#f09f33]
  [--fg:#f6c380]
  [--size:40px]
  [background-color:var(--bg)]
  [background-image:linear-gradient(135deg,_var(--fg)_25%,_transparent_25%),_linear-gradient(225deg,_var(--fg)_25%,_transparent_25%),_linear-gradient(315deg,_var(--fg)_25%,_transparent_25%),_linear-gradient(45deg,_var(--fg)_25%,_transparent_25%)]
  [background-position:calc(var(--size)_/_-2)_0,_calc(var(--size)_/_-2)_0,_0_0,_0_0]
  [background-size:var(--size)_var(--size)]
"></div>
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Zigzag — CSS background</title>
  <style>
    html, body { height: 100%; margin: 0; }
    .bg-zigzag {
      --bg: #f09f33;
      --fg: #f6c380;
      --size: 40px;
      background-color: var(--bg);
      background-image:
        linear-gradient(135deg, var(--fg) 25%, transparent 25%),
        linear-gradient(225deg, var(--fg) 25%, transparent 25%),
        linear-gradient(315deg, var(--fg) 25%, transparent 25%),
        linear-gradient(45deg, var(--fg) 25%, transparent 25%);
      background-position: calc(var(--size) / -2) 0, calc(var(--size) / -2) 0, 0 0, 0 0;
      background-size: var(--size) var(--size);
    }
  </style>
</head>
<body class="bg-zigzag"></body>
</html>

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

Zigzag 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 zigzag pattern works

The zigzag is built from four linear-gradient() layers on the same square tile. Each one paints a single triangle in one corner of the tile: --fg for the first 25% of the gradient, then transparent. The angles (45deg, 135deg, 225deg, 315deg) point the four triangles at the four corners.

Two of the layers are shifted half a tile to the left with background-position. That offset lines the triangles up so they join into one continuous zigzag band across the tile. When the tile repeats, the bands connect into rows of zigzags, also known as a chevron pattern.

--size sets the width of each zig and the space between rows. Even values keep the half-tile shift on whole pixels, which keeps the points sharp.

Use zigzags for playful headers, kids and party themes, retro packaging styles and section accents. The Tailwind tab outputs the same four layers for Tailwind v4.