What is the CSS Pattern Generator?
Generate CSS background patterns: dots, lines, grid, checkerboard, and diagonal stripes. Built entirely from CSS gradients - no image files.
Everything runs locally in your browser. Adjust the controls above, preview instantly, and copy clean, production-ready CSS — no account, no upload.
Using the CSS Pattern Generator
Everything lives in the panel at the top of this page. There is nothing to install — it all runs right here in your browser.
Select a pattern type
Choose dots, grid, diagonal stripes, checkerboard, cross, or zigzag. A live preview shows the pattern tiling.
Adjust size, spacing, and colour
Set the pattern element size, the background-size (controls tile repeat), and the foreground and background colours.
Copy the CSS
Click Copy to get the background-color, background-image, and background-size values together.
What the generated code looks like
Clean, production-ready CSS — no vendor bloat, no unnecessary declarations.
/* Dot grid pattern */
.dot-grid {
background-color: #f8fafc;
background-image: radial-gradient(#cbd5e1 1px, transparent 1px);
background-size: 24px 24px;
}
/* Diagonal stripes */
.stripes {
background: repeating-linear-gradient(
-45deg,
#f8fafc,
#f8fafc 5px,
#e2e8f0 5px,
#e2e8f0 10px
);
}
/* Graph paper */
.graph {
background-color: white;
background-image:
linear-gradient(rgba(108,46,245,0.1) 1px, transparent 1px),
linear-gradient(90deg, rgba(108,46,245,0.1) 1px, transparent 1px);
background-size: 24px 24px;
}CSS patterns are infinitely scalable, require no image files, and can be animated with background-position.
Ready-to-use CSS patterns
Drop any of these straight into your project — no modifications needed.
Pattern that fades out
Layer a mask over the pattern so it dissolves towards the content — common behind hero sections.
.hero-bg {
background-image: radial-gradient(#cbd5e1 1px, transparent 1px);
background-size: 22px 22px;
-webkit-mask-image: linear-gradient(to bottom, #000 40%, transparent);
mask-image: linear-gradient(to bottom, #000 40%, transparent);
}Theme-aware pattern with custom properties
Drive the colours from variables so the same pattern works in light and dark mode.
:root { --pat-bg: #ffffff; --pat-fg: #e2e8f0; }
@media (prefers-color-scheme: dark) { :root { --pat-bg: #0b1220; --pat-fg: #1e293b; } }
.checker {
background-color: var(--pat-bg);
background-image: conic-gradient(var(--pat-fg) 25%, transparent 0 50%, var(--pat-fg) 0 75%, transparent 0);
background-size: 32px 32px;
}Common mistakes & how to fix them
A few habits trip people up. Here is what to watch for — and the exact fix.
Pattern on the element that holds text
Busy patterns directly behind paragraphs reduce readability and contrast.
Fix: Put the pattern on a wrapper or ::before layer and give text a solid or semi-opaque panel.
Sub-pixel tile sizes
A background-size such as 13.5px makes lines blur or vary in thickness between tiles.
Fix: Use whole-pixel tile sizes and line widths so every repeat renders identically.
Pro tips for better results
background-size controls the tile repeat frequency
A smaller background-size repeats the pattern more densely. A larger one spaces it out. This value is independent of the dot or line size within the gradient.
Patterns can be animated by changing background-position
animation: slide 2s linear infinite; @keyframes slide { to { background-position: 24px 24px; } } creates a moving pattern.
Keep pattern contrast low for backgrounds
Patterns behind content should be subtle (5-15% opacity difference from background). High-contrast patterns compete with the content sitting on top.
Frequently asked questions
From the blog
Read more →CSS Box Shadow: A Complete Guide with Examples (2026)
Master CSS box-shadow: every value explained, layering multiple shadows for realistic depth, inset shadows, the spread trick, and copy-paste examples for cards, buttons, and more.
How to Create Glassmorphism in CSS: The Complete 2026 Guide
Learn how to build the frosted-glass effect with CSS backdrop-filter. Real code, the accessibility traps nobody mentions, browser support, and performance tips from production.
The Complete Guide to CSS Gradients (2026)
Master linear, radial, and conic CSS gradients. Learn color stops, angles, hard stops for stripes, multi-layer gradients, and the tricks behind smooth, professional results.