CSS Background Patterns: Five Repeats and Repeating Gradients

Open Tool CSS Background Pattern Generator

Fill without images

CSS patterns stack repeating-linear-gradient and radial-gradient layers — no image request, tiny payload, crisp at any resolution. Horizontal stripes repeat a linear gradient along one axis, vertical stripes rotate it ninety degrees, diagonals use forty-five degrees, dots repeat a radial gradient, and grids cross two perpendicular stripe layers. The tool exposes five presets with two colours: base and pattern.

Steps

  1. Pick horizontal, vertical, diagonal, dots or grid.
  2. Set base and pattern colours with moderate contrast.
  3. Adjust stripe thickness and spacing, dot size and pitch, or line width and cell size.
  4. Copy code for the background declaration and paste onto the container.
  5. Load the example or close the panel.

How repeating gradients work

Angle sets direction; stop positions set stripe width, with the gap between two stops defining one period. Equal stripes use stops like colour A from zero to two pixels and colour B from two to four, giving a four-pixel period. Dots rely on radial-gradient with background-size setting pitch, radius following stops. Grids comma-stack horizontal and vertical layers, with earlier declarations painting on top.

Legibility and mood

Pattern is ground, not subject, so keep contrast low — five to fifteen percent lightness difference lets text sit comfortably. Dark patterns under light text grey out; light patterns under dark text hold better. Direction guides the eye: vertical lengthens, horizontal widens, diagonal adds motion. Large areas need sparse density or hundreds of lines shimmer. Revealing pattern on a card edge reads more restrained than full coverage.

Common problems

Seams appear when stops do not close the loop, leaving a bright or dark hairline at the repeat. Pixel units mean transformed containers stretch the pattern. Some browsers drop complex backgrounds when printing unless background graphics are enabled. Many stacked layers cost paint time on weak devices. And an existing background-image is overwritten rather than merged.

When an image is better:Organic shapes, tactile textures and brushwork cannot be faked with gradients — use SVG patterns or raster. Complex art-directed grounds should not be assembled from gradients. Backgrounds that must reposition with content exceed CSS capabilities. And print output may lose CSS backgrounds in PDF pipelines, where SVG or raster travels safely.

⏫︎