Free tool · Design and colour
Pattern generator
Pick a pattern, set the colors, size and angle, and copy seamless CSS. Six patterns are plain gradients, waves use an SVG data URI, and most have an exact SVG tile to download.
- Free
- No sign-up
- Runs in your browser
Dots24 px cells, 3.6 px dot radius, #1D3557 on #F1FAEE
- CSS gradients only
- Seamless tile 24 x 24 px
- SVG tile ready
.pattern {
background-color: #F1FAEE;
background-image: radial-gradient(circle, #1D3557 3.6px, transparent 4.6px);
background-size: 24px 24px;
}
- CSS size
- 150 bytes
- Tile
- 24 x 24 px
- SVG tile
- 182 bytes
An SVG tile of the same picture is available. Apply the class to any element; the pattern repeats without seams.
How to use the Background Pattern Generator
- Choose a Pattern: stripes, dots, grid, checkerboard, diagonal grid, zigzag or waves.
- Pick a Pattern color and a Background color: type HEX, RGB or HSL, or tap a swatch.
- Move Size for the cell size, Thickness for the line or dot size, and Angle for stripes.
- Watch the preview at the top, then press Copy CSS. Where an SVG tile is offered, use Copy SVG or Download SVG tile.
How do I make a seamless background pattern in CSS?
Draw one small tile and let the browser repeat it. A background image repeats in both directions by default, and background-size sets the tile to an exact width and height. Every pattern here is built that way: one tile, drawn so its edges match the next tile, so no seam shows.
The default is dots, in 24 px cells with a dot radius of 3.6 px. It writes background-color: #F1FAEE, background-size: 24px 24px and a radial gradient that is navy up to a radius of 3.6 px and transparent just after it. The table shows what each pattern is made of at the default settings, how many bytes of CSS it takes, and whether an exact SVG tile exists.
| Pattern | Made with | CSS size | SVG tile |
|---|---|---|---|
| Stripes | CSS gradients | 150 bytes | No |
| Dots | CSS gradients | 150 bytes | Yes |
| Grid | CSS gradients | 200 bytes | Yes |
| Checkerboard | CSS gradients | 163 bytes | Yes |
| Diagonal grid | CSS gradients | 372 bytes | Yes |
| Zigzag | CSS gradients | 361 bytes | No |
| Waves | SVG data URI | 304 bytes | Yes |
Stripes show No in the table because the default angle is 45 degrees. At 0, 90 or 180 degrees they have an SVG tile as well.
Can I make a pattern with CSS gradients only?
Yes, for six of the seven. Stripes use repeating-linear-gradient. MDN defines 0deg as to top and 90deg as to right, so 90 degrees gives vertical stripes and 0 gives horizontal ones. The repeat length is the distance between the first and last color stop, which here is the cell size. At 24 px and 45 degrees the stripe is 3.6 px wide and the rest of each 24 px is background.
Dots use a radial-gradient with the circle keyword and two stops. A grid is two linear gradients, one per direction, each a line at the start of the tile. The diagonal grid is two linear gradients at 45 and 135 degrees whose line sits at the middle of the gradient. The zigzag is four triangles from linear gradients at 45, 135, 225 and 315 degrees, shifted against each other.
The checkerboard uses conic-gradient with hard stops at quarter turns. MDN lists conic-gradient as widely available since November 2020 and describes the same quadrant approach for a checkerboard. The tile holds two by two squares, so the tile is 48 px wide when each square is 24 px. Waves are the exception. A smooth wave cannot be drawn exactly from plain gradients, so waves use an SVG instead.
How do I use an SVG pattern as a CSS background?
Put the SVG in a data URL inside url(). The wave pattern does this. Its CSS is 304 bytes and begins background-image: url("data:image/svg+xml,%3Csvg .... MDN says reserved characters in a data URL must be percent-encoded, so the generator encodes %, #, < and >, and uses single quotes inside the SVG so the url() quotes stay intact.
The wave tile is 48 by 24 px. Its SVG is a single path, M0 12Q12 0 24 12T48 12 at the default size, which is a quadratic curve followed by its mirror image, so the line leaves each tile at the same height and angle it enters the next one.
For the other patterns, Download SVG tile gives a standalone file. Save it and use background: url(pattern.svg), or paste the SVG inline. A tile is offered only where it matches the CSS exactly: dots, grid, checkerboard, diagonal grid and waves always, stripes at 0, 90 and 180 degrees. Zigzag and stripes at other angles are CSS only. Large data URLs add weight to every stylesheet that holds them, so the result shows the CSS size in bytes.
How do I change the pattern color, size and angle?
Size is the cell in pixels, from 4 to 200. Thickness is a share of the size, from 5% to 50%, and it means the stripe width, the line width, the dot radius or the wave line width, depending on the pattern. Checkerboard and zigzag ignore it. Angle applies only to stripes and runs from 0 to 180 degrees. Colors accept HEX, RGB or HSL, and the CSS always writes HEX.
Worked example: stripes at 24 px and 15% write repeating-linear-gradient(45deg, #1D3557 0, #1D3557 3.6px, #F1FAEE 3.6px, #F1FAEE 24px). That is 15% of 24, or 3.6 px of navy, then 20.4 px of mint, so the pattern repeats every 24 px along the 45 degree line. The table gives the pixel value for other combinations.
| Thickness | 12 px cells | 24 px cells | 48 px cells |
|---|---|---|---|
| 5% | 0.6 px | 1.2 px | 2.4 px |
| 15% | 1.8 px | 3.6 px | 7.2 px |
| 25% | 3 px | 6 px | 12 px |
| 33% | 3.96 px | 7.92 px | 15.84 px |
| 50% | 6 px | 12 px | 24 px |
A thickness that is not a whole number of pixels, such as 3.6 px, ends between two screen pixels, so the edge may look slightly soft. Pick a size and thickness that multiply to a whole number for the crispest lines. To choose colors that work together, use the tint and shade generator, and check text laid over a pattern with the contrast checker. The CSS minifier trims the final stylesheet.
How do I keep text readable over a pattern?
Keep the two pattern colors close together. Under WCAG success criterion 1.4.3, body text needs a contrast ratio of 4.5:1 or more, and over a pattern the weakest spot behind the letters is what counts. The default pair, navy dots on mint, are 11.56:1 apart, which is a strong texture, and dark text laid across it would vanish on the navy parts. A softer pair works better behind text. Dots in #E3F2EF on #F1FAEE are only 1.08:1 apart, so text in #0F2138 stays at 14.06:1 or more everywhere on it.
Use a strong pattern for areas without text, such as page edges, hero shapes and empty states, and a faint one behind copy. The preview shows the pattern only, so check the real page with the colors you plan to use.
Use it with
- Tint and Shade Generator: lighter and darker steps of a color.
- Color Contrast Checker: WCAG contrast ratio.
- CSS Minifier: minify or beautify CSS.
Questions
How do I make a seamless background pattern in CSS?
Draw one tile and repeat it with background-size. For dots at 24 px the CSS is background-size: 24px 24px with a radial-gradient of radius 3.6 px. Pick any pattern here and copy the CSS.
Can I make a pattern with CSS gradients only?
Yes for stripes, dots, grids, checkerboards, diagonal grids and zigzags. Waves need an SVG, which the CSS carries as a data URL.
How do I use an SVG pattern as a CSS background?
Use background-image: url("data:image/svg+xml,...") with the SVG percent-encoded, or save the SVG tile as a file and point url() at it. Both are offered for waves; a downloadable tile exists for most other patterns.
How do I change the pattern color and size?
Type a color or use Pick for the pattern and the background. Size sets the cell from 4 to 200 px, and thickness sets the line or dot size as a share of it.
Which patterns have an SVG tile?
Dots, grid, checkerboard, diagonal grid and waves, and stripes at 0, 90 or 180 degrees. Zigzag and stripes at other angles are CSS only.
Is anything I choose sent to a server?
No. The CSS and the SVG are built in your browser and nothing you enter leaves your device.
Sources
- MDN: repeating-linear-gradient(), read
- MDN: radial-gradient(), read
- MDN: conic-gradient(), read
- MDN: background-size, read
- W3C WCAG 2.2: SC 1.4.3 Contrast (Minimum), read
- MDN: data URLs, read
The tool's results are computed in your browser by the code on this page, using the sources listed above; the explanations are checked against the tool's own output.