CSS techniques

Adding grain and noise texture to CSS gradients

Grain gives flat gradients a tactile, printed feel and hides colour banding. Here is how to add it with an SVG feTurbulence filter, a pseudo-element and the right blend mode.

To add grain to a CSS gradient, generate noise with an SVG feTurbulence filter, embed it as a data URI, and lay it over the gradient on a ::after pseudo-element with mix-blend-mode: overlay or soft-light and a low opacity. It adds well under a kilobyte, needs no image file, and also helps hide the colour banding that large gradients can show.

Key takeaways

  • SVG’s feTurbulence filter draws noise mathematically, so a tiny data URI can texture a full-screen background.
  • Put the grain on a pseudo-element with z-index: -1 and isolation: isolate on the parent, so text stays crisp on top.
  • overlay and soft-light keep colours rich; keep opacity low, around 0.15 to 0.4.
  • Grain breaks up the visible steps (banding) that appear in smooth gradients on some screens.

Why add grain to a gradient?

Smooth digital gradients can look flat and slightly plastic, and on many displays they show bands: visible steps where one shade jumps to the next because there aren’t enough colour values to fill a wide area smoothly. Film and print never had that problem, because their natural texture scattered the colours. Adding a faint layer of noise does the same job on screen. It hides the bands, adds depth, and gives designs the tactile quality you see on many modern landing pages and brand illustrations.

How do you add grain in CSS?

Here is the full pattern. The SVG draws a square of noise, CSS tiles it over the element, and the blend mode mixes it into the gradient underneath:

.grainy {
  position: relative;
  isolation: isolate;
  background: linear-gradient(135deg, #ff7a59, #7b5cff);
}

.grainy::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
  opacity: .35;
  pointer-events: none;
}

What each part does

  • isolation: isolate creates a new stacking context, so the z-index: -1 pseudo-element sits above the parent’s background but below its text and children.
  • type="fractalNoise" gives soft, even grain. turbulence gives a streakier, more liquid pattern.
  • baseFrequency sets the grain size. Higher numbers give finer speckles; around 0.6 to 0.9 looks like film grain.
  • numOctaves adds layers of finer detail. Two to four is plenty; more costs rendering time for little visible change.
  • stitchTiles="stitch" makes the edges of the tile line up, so there are no visible seams when it repeats.
  • pointer-events: none stops the overlay from catching clicks.

Which blend mode should you use for grain?

Blend modeEffectGood for
overlayAdds texture to lights and darks, boosts contrast slightlyBold, saturated gradients
soft-lightGentler version of overlayPastel and subtle backgrounds
multiplyDarkens; grain shows as dark specksLight backgrounds, a paper feel
screenLightens; grain shows as light specksDark backgrounds, a starry or dusty feel
normalNo blending, just grey noise on topRarely; it tends to wash colours out

Whichever you pick, start with low opacity and raise it until you can just see the texture at normal viewing distance. Grain that is obvious in a zoomed-in screenshot is often perfect at real size, and grain that looks perfect when zoomed in is often too faint on a phone.

Does grain fix gradient banding?

It helps a lot. Banding happens because an 8-bit display has only 256 levels per colour channel, so a gradient across a 2,000-pixel-wide hero has to repeat each shade over several pixels, producing visible stripes, especially in dark blues and greys. Noise randomly nudges neighbouring pixels up and down, a technique called dithering, so your eye blends the steps into a smooth ramp. You don’t need much: an opacity of 0.1 to 0.2 is usually enough to hide banding without the texture becoming a visible style.

Pairing: Grain pairs especially well with CSS mesh gradients, which have large soft areas where banding is most likely.

Is CSS grain bad for performance?

For static backgrounds, no. The browser renders the noise tile once and reuses it, and the data URI is only a few hundred bytes. Two things are worth avoiding:

  • Animating the grain over large areas, for example shifting its position every frame for a film flicker. That forces a repaint of the whole area each frame and can drain batteries on phones.
  • Stacking it on dozens of elements. Apply it to the few large surfaces that need it, such as the hero and section backgrounds, rather than to every card.

If you want to avoid the filter entirely, download a seamless PNG tile instead and use it as a normal background image. It costs a small download but nothing to render.

Can you add grain to photos or text?

Yes. The same pseudo-element works over a photo or a background-image, which can help a stock image sit more naturally next to a grainy illustration style. Avoid putting grain directly over body text, though: speckles inside small letters reduce legibility and can lower the effective contrast. Keep the texture on the background layer, as in the pattern above, and check your text against the result with a contrast checker.

Using grain in WordPress and page builders

The generator’s “Paste into” menu rewrites the CSS for Elementor, Divi, Bricks, Breakdance or the block editor and shows where to paste it. In Elementor Pro and Divi 5 the code uses selector, so the grain only lands on the section you add it to.

Try it

The Refract grain and noise texture generator lets you pick the gradient, grain size, detail, strength and blend mode with a live preview, then copy the CSS or download a seamless PNG tile. For the gradient underneath, try the CSS gradient generator or the mesh gradient generator.

Last checked: October 2026.

Sources: MDN: <feTurbulence>, MDN: mix-blend-mode, MDN: isolation.