CSS Checkerboard Background

A checkerboard background in pure CSS made with a single conic-gradient. Adjust square size and both colors live, then copy the CSS, Tailwind or HTML demo.

#223b8c
#7585b7
24px
.bg-checkerboard {
  --bg: #223b8c;
  --fg: #7585b7;
  --size: 24px;
  background-color: var(--bg);
  background-image: conic-gradient(var(--fg) 25%, transparent 0 50%, var(--fg) 0 75%, transparent 0);
  background-size: calc(var(--size) * 2) calc(var(--size) * 2);
}
<div class="
  [--bg:#223b8c]
  [--fg:#7585b7]
  [--size:24px]
  [background-color:var(--bg)]
  [background-image:conic-gradient(var(--fg)_25%,_transparent_0_50%,_var(--fg)_0_75%,_transparent_0)]
  [background-size:calc(var(--size)_*_2)_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>Checkerboard — CSS background</title>
  <style>
    html, body { height: 100%; margin: 0; }
    .bg-checkerboard {
      --bg: #223b8c;
      --fg: #7585b7;
      --size: 24px;
      background-color: var(--bg);
      background-image: conic-gradient(var(--fg) 25%, transparent 0 50%, var(--fg) 0 75%, transparent 0);
      background-size: calc(var(--size) * 2) calc(var(--size) * 2);
    }
  </style>
</head>
<body class="bg-checkerboard"></body>
</html>

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

Checkerboard 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 checkerboard pattern works

A conic-gradient() sweeps around the center of its box like a clock hand, so it can split the box into four quarters. Here the first and third quarters (top right and bottom left) are --fg, and the other two are transparent so --bg shows through.

Each 0 in the color stops makes a hard edge, so every quarter is a clean square with no blending.

The tile is two squares wide (calc(var(--size) * 2)), so --size is the size of one square on the board. Tiling that 2×2 block gives the full checkerboard.

Change --size for bigger or smaller squares, and set --fg and --bg to recolor it. Black and white gives a classic board. Light gray on white is the usual “transparent” background behind image editors and color pickers. Two close colors make a subtle texture for cards.