Pick a pattern, set the colors, tile size and thickness, and get clean CSS that draws it with gradients only. No image files, no extra HTTP requests, and the pattern stays sharp at any zoom level.
Last updated:
Advertisement
Advertisement
How to use the CSS Background Pattern Generator
Choose a pattern from the gallery at the top (arrow keys also work).
Pick the colors with the pickers, hex fields or a preset, or press Randomize colors.
Adjust tile size and thickness, plus the angle for stripes and the opacity for a subtler texture.
Choose the code format: longhand CSS is easiest to edit, shorthand is compact, HTML demo is a ready test page.
Copy or download the code and add the class to any element, such as <body class="pattern">.
How pure CSS patterns work
A CSS pattern is made of gradient layers. Each layer is drawn inside a tile whose size comes from background-size, and the browser repeats that tile in both directions. Three ideas do almost all the work:
Hard stops. Two stops at the same position, like #000 50%, transparent 50%, create a sharp edge instead of a fade.
Layer stacking. The first layer in background-image is painted on top. Combining two or four layers produces grids, zigzags and diamonds.
Offsets.background-position shifts individual layers, for example by half a tile to stagger polka dots.
radial-gradient(circle, …), two offset layers for polka
Playful sections, subtle page textures
Checkerboard
repeating-conic-gradient in 25% steps
Transparency backgrounds, game boards, racing themes
Grid, graph paper
Thin linear-gradient lines in two directions
Blueprint and notebook looks, design canvases
Zigzag, diamonds
Four linear-gradient triangles at 45° steps
Headers, packaging-style backgrounds
Gingham
Two semi-transparent bands that overlap
Picnic, food and farmhouse designs
Triangles
conic-gradient with a 60° slice
Geometric hero sections
Waves, half circles, ripples
radial-gradient rings and arcs
Water, retro and Art Deco styles
Tips for using patterns on real pages
Behind body text, keep the contrast between the two pattern colors low and the opacity at 10 to 30%, or place text on a solid card.
Use background-attachment: fixed for a pattern that stays still while content scrolls over it.
Very small tiles (under 8px) can shimmer (moiré) when the page is zoomed or scrolled; sizes from 16px up look calmer.
Store the colors in custom properties, e.g. --p1 and --p2, to switch the pattern's theme with one line.
Frequently asked questions
How do you make a background pattern with only CSS?
Stack one or more gradients in background-image and make them repeat with background-size. Each gradient draws a shape inside one tile, such as a circle from radial-gradient or a triangle from linear-gradient with a hard stop, and the browser tiles it across the element. The generator writes these layers for you.
Are CSS gradient patterns better than image patterns?
For simple geometric patterns, usually yes: they weigh a few hundred bytes, need no extra request, scale perfectly on high-density screens and can be recolored by editing a hex value. Complex illustrated patterns are still better as SVG or PNG files.
How do I make hard-edged stripes with CSS?
Put two color stops at the same position so there is no blend, for example repeating-linear-gradient(45deg, #2f6b4f 0 20px, transparent 20px 40px). The first color fills 0 to 20px, the second 20px to 40px, and the pattern repeats every 40px.
Do these patterns work in all browsers?
Linear and radial gradients work in every current browser. The checkerboard and triangles use conic-gradient, which is supported by Chrome, Edge, Firefox and Safari since 2021. Older browsers simply show the background color.
How can I make the pattern more subtle behind text?
Lower the pattern opacity slider or choose two close colors. The output then uses an rgba() color for the pattern, so the background color shows through. Check text readability with a contrast checker after adding a pattern.
Can I animate a CSS pattern?
Yes. Animating background-position moves the pattern, for example from 0 0 to the tile size, which creates a seamless scrolling effect. Keep the animation slow and respect prefers-reduced-motion for visitors who dislike movement.
Are all the tools on FreeToolCabin tested for quality and accuracy?
Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.