CSS Crosshatch Background
A crosshatch background in pure CSS: two sets of fine diagonal lines crossing like pen hatching. Set line spacing and thickness live, then copy CSS or Tailwind.
.bg-crosshatch {
--bg: #cc3f47;
--fg: #df878c;
--size: 12px;
--line: 1.5px;
background-color: var(--bg);
background-image:
repeating-linear-gradient(45deg, transparent 0 calc(var(--size) - var(--line) - 1px), var(--fg) calc(var(--size) - var(--line)) var(--size)),
repeating-linear-gradient(-45deg, transparent 0 calc(var(--size) - var(--line) - 1px), var(--fg) calc(var(--size) - var(--line)) var(--size));
}<div class="
[--bg:#cc3f47]
[--fg:#df878c]
[--size:12px]
[--line:1.5px]
[background-color:var(--bg)]
[background-image:repeating-linear-gradient(45deg,_transparent_0_calc(var(--size)_-_var(--line)_-_1px),_var(--fg)_calc(var(--size)_-_var(--line))_var(--size)),_repeating-linear-gradient(-45deg,_transparent_0_calc(var(--size)_-_var(--line)_-_1px),_var(--fg)_calc(var(--size)_-_var(--line))_var(--size))]
"></div><!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Crosshatch — CSS background</title>
<style>
html, body { height: 100%; margin: 0; }
.bg-crosshatch {
--bg: #cc3f47;
--fg: #df878c;
--size: 12px;
--line: 1.5px;
background-color: var(--bg);
background-image:
repeating-linear-gradient(45deg, transparent 0 calc(var(--size) - var(--line) - 1px), var(--fg) calc(var(--size) - var(--line)) var(--size)),
repeating-linear-gradient(-45deg, transparent 0 calc(var(--size) - var(--line) - 1px), var(--fg) calc(var(--size) - var(--line)) var(--size));
}
</style>
</head>
<body class="bg-crosshatch"></body>
</html>Save the pattern as an image, with your current colors and settings.
Crosshatch 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 crosshatch pattern works
Crosshatching is two sets of diagonal lines laid over each other. Each set is a repeating-linear-gradient(): transparent for most of the repeat, then --fg for the last --line pixels. One runs at 45deg and the other at -45deg, so they cross at right angles and form a fine diamond mesh.
There’s a one-pixel gap between the transparent stop and the line, which softens the leading edge of each line. Thin diagonal lines with two hard edges can look jagged. One soft edge keeps them smooth.
Because both layers repeat on their own, there’s no tile and no seam. --size sets the distance between lines and --line their thickness. Small spacing with thin lines reads as a texture, the way pen-and-ink artists shade. Wider spacing gives an open lattice.
Use crosshatch as a subtle texture behind cards and hero sections, for sketchbook and hand-drawn themes, and as a light “shaded” area in charts. The Tailwind tab outputs both layers for Tailwind v4.