CSS Polka Dots Background
A classic polka dot background made with two radial gradients and no images. Change the dot color, size and spacing live, then copy the CSS or Tailwind.
.bg-polka-dots {
--bg: #880088;
--fg: #b560b5;
--size: 32px;
--dot: 40%;
background-color: var(--bg);
background-image:
radial-gradient(circle closest-side, var(--fg) var(--dot), transparent calc(var(--dot) + 1px)),
radial-gradient(circle closest-side, var(--fg) var(--dot), transparent calc(var(--dot) + 1px));
background-size: var(--size) var(--size);
background-position: 0 0, calc(var(--size) / 2) calc(var(--size) / 2);
}<div class="
[--bg:#880088]
[--fg:#b560b5]
[--size:32px]
[--dot:40%]
[background-color:var(--bg)]
[background-image:radial-gradient(circle_closest-side,_var(--fg)_var(--dot),_transparent_calc(var(--dot)_+_1px)),_radial-gradient(circle_closest-side,_var(--fg)_var(--dot),_transparent_calc(var(--dot)_+_1px))]
[background-size:var(--size)_var(--size)]
[background-position:0_0,_calc(var(--size)_/_2)_calc(var(--size)_/_2)]
"></div><!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Polka Dots — CSS background</title>
<style>
html, body { height: 100%; margin: 0; }
.bg-polka-dots {
--bg: #880088;
--fg: #b560b5;
--size: 32px;
--dot: 40%;
background-color: var(--bg);
background-image:
radial-gradient(circle closest-side, var(--fg) var(--dot), transparent calc(var(--dot) + 1px)),
radial-gradient(circle closest-side, var(--fg) var(--dot), transparent calc(var(--dot) + 1px));
background-size: var(--size) var(--size);
background-position: 0 0, calc(var(--size) / 2) calc(var(--size) / 2);
}
</style>
</head>
<body class="bg-polka-dots"></body>
</html>Save the pattern as an image, with your current colors and settings.
Polka Dots in other colors
Click a color to try it in the preview above, then copy the code.
Browse by color: Red · Orange · Yellow · Green · Teal · Blue · Purple · Pink
How the polka dots pattern works
Each tile is a square --size wide. Inside it, radial-gradient(circle closest-side, …) draws one round dot in the center. closest-side means 100% is the distance from the center to the tile’s edge, so --dot: 40% gives a dot whose diameter is 40% of the tile.
The second gradient is the same dot, shifted half a tile right and down with background-position. That’s what gives the classic staggered polka-dot layout instead of a straight grid.
The + 1px in the second color stop softens the edge by one pixel, so the dots stay round instead of jagged.
To change it, set --fg for the dots, --bg for the background, --size for spacing and --dot for dot size. Keep --size an even number of pixels so the shifted layer lands on whole pixels. Polka dots work well behind empty states, pricing cards and playful hero sections. Use a soft --fg close to --bg if text sits on top.