- 8-bit color gives 256 levels per channel, and a gradient can run out of steps before it runs out of space.
- A thin layer of noise breaks up visible color bands by scattering the eye's attention across the step.
- SVG's feTurbulence filter generates procedural noise with no image file to download at all.
- Random noise compresses poorly, so a grain image file is often heavier than the gradient it covers.
Why smooth gradients band
Most images on the web store color at 8 bits per channel, which allows exactly 256 distinct levels of red, green and blue. That sounds like plenty, and for a photograph full of fine detail it usually is. A long, smooth gradient is a different case: it has to represent a slow, continuous change in color across potentially thousands of pixels using only those 256 steps.
When the gradient is long and the color change is subtle, a single 8-bit step can cover many pixels in a row. The eye is good at spotting edges, and a row of identical pixels next to a row that is one step different reads as a visible line, a band, rather than a smooth transition. This shows up most on large, low-contrast gradients, exactly the kind used behind hero text or a calm section background.
CSS gradients, whether written as linear-gradient() or radial-gradient(), are rendered by the browser at the device's own color depth, so the same banding risk applies whether the gradient comes from an image file or from CSS syntax directly. A long, nearly flat gradient between two close colors is the riskiest case, since each step covers the most pixels before moving on to the next.
Grain as a fix, and as a look
Adding a small amount of noise, random per-pixel brightness variation, breaks up the flat steps that cause banding. Instead of a hard line between one color level and the next, the noise scatters pixels from both levels across the border, which the eye reads as a smooth gradient again even though the underlying math has not changed.
This also doubles as a deliberate style choice independent of banding. Grain adds warmth and texture to an otherwise flat, digital-feeling surface. The subtle grain gradient set on this site combines a soft color gradient with fine film grain for exactly this reason: the grain is visible as texture and happens to solve the banding problem in the same image.
This technique has a long history outside the browser too. Dithering, the practice of adding controlled noise before quantizing an image to fewer colors, solves the same underlying problem in print and in older, lower color-depth displays. The web use case is newer, but the underlying math, trading a small amount of random error for the appearance of a smoother gradient, is the same idea applied to a modern 8-bit screen.

Generating noise with SVG feTurbulence
SVG includes a filter primitive built for exactly this: feTurbulence generates procedural noise mathematically, with no source image at all.
<svg>
<filter id="grain">
<feTurbulence type="fractalNoise"
baseFrequency="0.9"
numOctaves="2"
result="noise"/>
<feColorMatrix in="noise" type="matrix"
values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.05 0"/>
</filter>
</svg>baseFrequency controls how fine or coarse the noise looks, and numOctaves layers several frequencies together for a more natural, less uniform pattern. The feColorMatrix step above turns the colored noise into a faint, low-opacity overlay by zeroing out color and keeping only a small amount of alpha. Apply the filter to an element with filter: url(#grain), or reference it inside an <feImage> composite for more control over how it blends with content underneath.
Why shipped noise images are heavy
Random noise is the worst case for lossy compression. Formats like JPEG and lossy WebP work by finding patterns and smooth runs of similar pixels and representing them compactly. Noise has neither: each pixel differs unpredictably from its neighbors, so there is little to compress, and a grainy image often ends up larger than a smooth one of the same pixel dimensions, sometimes noticeably so.
This is the practical argument for generating grain at render time with feTurbulence, or with a canvas or shader approach, instead of baking it into every exported JPEG. A procedural filter costs some rendering time on the client, but zero bytes over the network. A baked-in grain image costs bytes every time, for every visitor, on every page load, the same budget covered in fast background images.
There is a middle path worth knowing: a small, tileable noise PNG, repeated with background-repeat, pays its download cost once and then reuses the same tiny file everywhere. A 64 by 64 or 128 by 128 noise tile is light enough that the compression penalty barely matters, since the whole file is small to begin with, even though noise compresses worse per pixel than a smooth surface would.

Blending grain over existing backgrounds
Noise usually looks best as a thin layer over something else, not as a background on its own. CSS background-blend-mode or mix-blend-mode, covered in more depth in background-blend-mode and mix-blend-mode, lets a grain layer interact with the color beneath it instead of simply covering it.
.panel {
background-image: url("noise.png"), linear-gradient(180deg, #1a1f3d, #2b2f77);
background-blend-mode: overlay;
}overlay and soft-light both let the noise darken shadows and lighten highlights slightly rather than sitting as a flat, visible layer on top. Keep the noise image's own contrast low. A grain texture built for this purpose, rather than a sharp black and white static pattern, blends in as texture instead of reading as a separate graphic element.
The order of the comma-separated list in background-image matters: the first layer listed sits on top. Put the noise first and the gradient or photo second if you want the blend mode to act on the noise against the layer beneath it, and check the result against both a light and a dark section if your page supports a dark theme, since the same blend mode can read very differently depending on what sits underneath.
How much noise is enough
More noise is not automatically better. The goal is to interrupt banding and add a sense of material, not to make the surface look dirty or low quality.
- Start at a low opacity, often under 10 percent, and increase only until the bands disappear.
- Keep noise fine-grained for a photographic, film-like feel; coarse noise reads as static or a defect.
- Test on the actual target screens. A high density display can make fine noise nearly invisible, while a lower density screen shows it clearly.
- Reduce or remove noise behind body text, since fine random variation can lower perceived legibility even without changing measured contrast.
A background like the synthwave grid background uses sharp lines and bold color rather than noise, which is the right call for a style built on crisp edges. Grain suits calmer, photographic or painterly surfaces far more than graphic, vector-flat ones.
A useful check is to zoom a mockup out to actual viewing size on the target device rather than judging it at 200 percent in an editor. Grain that looks tasteful at a large zoom level often disappears almost entirely at real size, while grain that looks subtle up close can read as visible static once the whole page is in view.
Performance notes
A procedural filter like feTurbulence is not free. It runs on every paint, and on a large element or an animated gradient it can cost noticeably more than a static image would, especially on lower powered devices. Test real frame rates before applying it broadly, particularly on an element that scrolls, resizes or re-renders often.
A practical middle ground: generate the noise once with SVG, render it to a small tile, and reuse that tile as a lightweight repeating background rather than recomputing the filter continuously. This keeps the zero-network-cost benefit of procedural noise while avoiding repeated, expensive filter recalculation on every frame.
If the page already loads a heavy hero image, weigh whether a grain layer is worth the extra paint cost at all. A background that is already busy and photographic, such as a rusted metal texture, carries its own fine detail and rarely needs added noise on top. Reserve grain for the flat, smooth surfaces that actually show banding or need the extra warmth.
Noise and dark mode
A grain overlay tuned for a light surface rarely survives a straight swap to a dark theme. The same opacity of noise reads as far more visible against a dark, low-luminance background than against a light one, since the contrast between the random pixel values and the base color is larger in the dark.
If a site supports prefers-color-scheme: dark, treat the grain opacity and blend mode as theme-specific values rather than a single fixed setting. A lower opacity, or a switch from overlay to a gentler mode such as soft-light, often keeps the texture feeling consistent between light and dark without it turning harsh in one of the two themes.



