CSS background pattern generator

A CSS background pattern is a repeating texture drawn with gradients, so it needs no image file. Pick dots, stripes, a grid or a checkerboard below and copy the ready background-image CSS or Tailwind class.

Pick a pattern, set the colours, size and line thickness, and copy the CSS: every pattern is built from CSS gradients, so there is no image to download and it scales sharply on any screen.

Live preview

CSS

.pattern {
  background-color: #ffffff;
  background-image: radial-gradient(rgb(99, 102, 241) 4px, transparent 4.5px);
  background-size: 24px 24px;
}

Tailwind

bg-[radial-gradient(rgb(99,_102,_241)_4px,_transparent_4.5px)]

How CSS background patterns work

A pattern is a small tile drawn with a gradient and repeated by the browser. Dots use a radial-gradient that paints one circle per tile, while stripes use a repeating-linear-gradient that redraws the same band at a fixed angle. A grid is two linear-gradient layers, one for the vertical lines and one for the horizontal lines.

The background-size property sets the size of that tile, so it controls the spacing between dots or the width of each stripe. Change the colour stops to set the line thickness, and layer several gradients with comma-separated background-image values when a pattern needs more than one shape.

Pattern recipes

PatternCSS functionBest for
Dotsradial-gradientSubtle section backgrounds
Stripesrepeating-linear-gradientBanners and progress bars
GridTwo linear-gradientsCanvas and blueprint looks
Checkerboardconic-gradientTransparency backgrounds

Frequently asked questions

How do I make a polka dot background in CSS?

Use a radial-gradient as the background-image and set background-size to the spacing you want between dots. The gradient draws one dot per tile, and the browser repeats the tile across the element.

How do I make striped backgrounds in CSS?

Use repeating-linear-gradient with two colour stops and an angle. The repeating function redraws the stripe every time the pattern reaches the end of the stop list, so you only set the stripe width once.

Are CSS patterns better than background images?

For simple dots, stripes, grids and checkerboards, yes. A CSS pattern is a few lines of code, needs no image request, stays sharp on every screen and can be recoloured with a variable instead of a new file.

How do I keep a pattern behind text readable?

Keep the pattern low contrast against the background and put the text on a solid or semi-transparent panel. Check the text and panel colours with a contrast checker rather than the pattern itself.

Related: style the scrollbar to match.

More CSS generators

Color tools

Image tools

Image & SVG tools

Typography & units

More free tools

All free tools