100% Free & Client-Side: All 92 tools run locally inside your browser — zero server uploads, zero signups.
Home / Blog / CSS Background Patterns: SVG, Gradients & Copy-Paste Code
100% free · runs in your browser

CSS Background Patterns: SVG, Gradients & Copy-Paste Code

Repeating patterns add texture to hero sections, cards and dashboards without a single image file. Here are the two best techniques and ready-to-use code.

Technique 1: CSS gradients

Gradients can draw dots, grids and stripes with no extra files.

Dot pattern

background-color: #0f172a;
background-image: radial-gradient(#6366f1 2px, transparent 2px);
background-size: 24px 24px;

Grid pattern

background-color: #0f172a;
background-image:
  linear-gradient(rgba(99,102,241,.35) 1px, transparent 1px),
  linear-gradient(90deg, rgba(99,102,241,.35) 1px, transparent 1px);
background-size: 24px 24px;

Diagonal stripes

background-image: repeating-linear-gradient(45deg, #6366f1 0 2px, transparent 2px 12px);

Technique 2: inline SVG data URI

An SVG tile encoded in the URL gives you shapes gradients cannot easily draw, such as zigzags, waves and plus signs. It scales perfectly on high-density screens and adds no network request. Our CSS Background Pattern Generator builds the SVG and the CSS for you and lets you download the SVG file.

Tips for good-looking patterns

Frequently Asked Questions

How do I make a dotted background in CSS?

Use a radial-gradient with background-size, for example radial-gradient(#6366f1 2px, transparent 2px) with a 24px tile.

Are SVG patterns better than PNG patterns?

SVG stays sharp at any resolution and is usually much smaller than a PNG.

Can I animate a CSS pattern?

Yes. Animate background-position to make the pattern slowly move.

Related Tools