CodeKitHub
CSS Tools

CSS Background Pattern Generator

Last updated:

This tool generates repeating background patterns using only CSS gradients — no image files required. Pick polka dots, diagonal stripes, a checkerboard, or grid lines, adjust the colors and spacing, and copy the background-image CSS straight into your stylesheet.

Preview

Generated CSS

What Is This Tool?

CSS can draw repeating patterns without any image files by using gradients — radial-gradient() and linear-gradient() — as a background-image, combined with a background-size that's smaller than the element so the gradient tiles and repeats. Polka dots use a repeating radial-gradient, stripes and checkerboards use repeating or layered linear-gradient(), and grid lines use two overlapping linear-gradient() lines.

This tool builds those gradient declarations for you. Pick a pattern type, adjust the pattern color, background color, and spacing, and watch the live preview update — then copy the exact background-image and background-size CSS.

Source: CSS Images Module Level 3, W3C — defines repeating-linear-gradient() and repeating-radial-gradient(), the functions these patterns are built from.

Why Use It?

  • No image files, no HTTP requests — the pattern is pure CSS and renders instantly at any resolution, including retina/high-DPI screens.
  • Fully adjustable color and spacing without hand-writing gradient syntax or calculating tiling math.
  • Live preview shows the exact repeating pattern before you copy anything.
  • Scales cleanly since it's vector math, not a raster image — no blurring when the element resizes.
  • Runs entirely in your browser — nothing you configure is uploaded anywhere.
  • Free, no signup, works on mobile.

How to Use

  1. Choose a pattern type: polka dots, diagonal stripes, checkerboard, or grid lines.
  2. Pick the pattern color and the background color that shows between/behind the pattern shapes.
  3. Adjust the size slider to make the dots, stripes or grid cells larger or smaller — this also controls how densely the pattern repeats.
  4. Copy the generated CSS and paste it as the background-image (and background-size/background-position where shown) of any element.

Example

Input

Pattern: polka dots · Color: blue · Background: white · Size: 24px

Output

background-color: #ffffff;
background-image: radial-gradient(rgba(59, 130, 246, 1) 3px, transparent 3px);
background-size: 24px 24px;
background-position: 0 0;

A classic light polka-dot pattern often used as a subtle section background or card texture.

How each pattern is built

  • Polka dots: a radial-gradient() draws one small filled circle, then background-size makes it repeat as a tiled grid of dots.
  • Diagonal stripes: a repeating-linear-gradient() at a 45-degree angle alternates between the pattern color and background color at a fixed interval.
  • Checkerboard: two overlapping 45-degree linear-gradient() layers, offset from each other by half a tile, produce alternating light/dark squares.
  • Grid lines: two thin linear-gradient() lines — one horizontal, one vertical — tiled at the chosen spacing to form a grid, similar to graph paper.

When to use CSS patterns instead of image files

A CSS gradient pattern has no file size and no HTTP request, so it loads instantly and never looks blurry on high-DPI screens, unlike a raster PNG background tile. It's ideal for subtle textures behind text, section dividers, empty-state illustrations, or placeholder cards. For complex illustrated or photographic patterns, an actual image is still the right tool — CSS gradients are best suited to simple, geometric, repeating shapes like the ones here.

Pairing with other CSS effects

Patterns work well as a backdrop behind glassmorphism cards, since the blur needs something with visual texture behind it to be visible. They also pair naturally with rounded corners on the container element.

→ CSS Glassmorphism Generator · Border Radius Generator

Frequently Asked Questions

Do these patterns require any image files?

No. Every pattern here is generated purely with CSS gradients as a background-image — there's no PNG, SVG or other file involved, so there's no extra HTTP request and no risk of blurring on high-resolution screens.

Can I change how big the pattern is?

Yes — the size slider controls background-size, which sets how large one repeating tile of the pattern is. A smaller size packs the dots, stripes or grid cells closer together; a larger size spreads them out.

Why does the checkerboard pattern use two gradients?

A single linear-gradient() can only alternate colors along one direction. Layering two 45-degree gradients, offset from each other by half a tile, is what produces the alternating light/dark squares of a checkerboard — this is the standard technique for CSS-only checkerboards.

Will this pattern look sharp on retina/high-DPI screens?

Yes. Because the pattern is a mathematical gradient rather than a bitmap image, it's rendered at whatever resolution the screen needs, with no upscaling or blurring — unlike a small raster image tile stretched or repeated at high pixel density.

Can I use these patterns as a full-page background?

Yes — apply the generated background-image, background-size and background-position (where present) to the body or any full-width container element. Keep contrast in mind: a busy, high-contrast pattern behind body text can hurt readability, so lighter/subtler settings usually work better for large background areas.

Related Tools