Tune a repeating CSS pattern without an image file
Admin ·
Use a repeating CSS gradient for a background whose geometry can be adjusted in pixels. Set the repeat size, then decide how much of each repeat should be filled with the pattern color.
Adjust dot spacing without changing the dot diameter
Select Reset settings to start with Dots. A 24 px square tile holds one centered dot with radius 4 px, so each dot is 8 px across and the centers are 24 px apart.
Change Repeat size to 36 px. The dots remain 8 px across and their centers move 36 px apart. In Generated CSS, look for background-size: 36px 36px and the same 4 px color stop.
.pattern-background {
background-color: #e8f2e5;
background-image: radial-gradient(circle at center, #266a5d 0px 4px, transparent 4px);
background-size: 36px 36px;
background-repeat: repeat;
}W3C CSS Images Level 4, gradientsW3C CSS Backgrounds and Borders, background sizing
Compare the repeat geometry of checks and stripes
Choose Checkerboard and keep 36 px. Its conic-gradient fills alternating quarters of the tile, so each visible square is 18 px on a side. The whole tile still repeats every 36 px.
Choose Stripes, set the line thickness to 6 px and the angle to 90 degrees. The gradient now repeats a 6 px vertical stripe and a 30 px clear gap across the width.
W3C CSS Images Level 4, gradientsW3C CSS Backgrounds and Borders, background sizing
Apply and check the pattern in your layout
Download pattern-background.css and apply its class to a visible element. Make the element wider and confirm the pattern adds repeats with the same spacing. The background color remains visible through the transparent parts of the gradients.
If a dot grows larger than half its tile, lower the radius or increase the repeat size. For patterns behind text, check that the text is readable over both pattern and background colors.
W3C CSS Backgrounds and Borders, background sizingW3C WAI, understanding Contrast Minimum
Common questions
Why can similar line thicknesses look different at an angle?
A stripe's thickness is measured along the gradient direction. At an angle, the same stripe crosses more horizontal or vertical pixels.
Can I make a lower-contrast pattern without changing its spacing?
Choose pattern and background colors closer together. The repeat size and radius or thickness stay the same.