Noise is a familiar texture in static design work: designers add it to solid colors and smooth gradients so shadows and lighting read as more natural. On the web the technique is used far less often, but a grain effect can be built from a small amount of CSS and SVG.
How the effect is assembled
The approach layers an SVG-generated noise texture beneath a CSS gradient, then pushes that noise toward white and black so it reads as grain rather than a muddy haze. It builds on a Stack Overflow answer by Chris Pachl on adding noise to a CSS3 gradient.
The pieces
- SVG turbulence: an SVG filter supplies the noise itself.
- Background with gradient and SVG: the filter is referenced in CSS as a background image combined with a gradient.
- Brightness and contrast: the CSS
filterproperty is used to sharpen the noise. - Blending:
mix-blend-modeoptionally filters out unwanted colors and merges stacked gradients.
Generating noise with <feTurbulence>
SVG lets you define filters, and <feTurbulence> is the one that produces Perlin noise. Its attributes control whether the output is "turbulence" or "noise" and how fine or coarse the result looks. Bence Szabó's write-up on creating patterns with SVG filters covers the filter in more depth.
<svg viewBox="0 0 200 200" xmlns='http://www.w3.org/2000/svg'>
<filter id='noiseFilter'>
<feTurbulence
type='fractalNoise'
baseFrequency='0.65'
numOctaves='3'
stitchTiles='stitch' />
</filter>
<rect width='100%' height='100%' filter='url(#noiseFilter)' />
</svg>
Above, the filter is defined separately from a <rect>, which renders it; the <rect> simply references the filter. This SVG is saved as its own file and fetched by URL in the demos. In production you would point to a local file or your own CDN. Referencing the SVG by id from CSS does not work, for reasons the source calls quirky; inlining the SVG is an alternative, as the playground demo does.
Combining the SVG with a gradient
With the SVG stored at a URL or path, it can be used in a CSS background alongside a gradient.
.noise {
/* ... */
background:
linear-gradient(to right, blue, transparent),
url(https://grainy-gradients.vercel.app/noise.svg);
}
Order matters. The goal in this example is a solid color that transitions into noise and then into a second color, with one end of the gradient transparent so the noise shows through. Plain noise alone is too muddled at this stage, so it needs to be frayed into something grainier.
Sharpening with brightness and contrast
A CSS filter makes the noise more stark by pushing the most faded colors toward white or black. Because the filter applies to the whole <div>, colors shift: the leftmost blue ends up a different blue than the pure blue it started from.
.noise {
/* ... */
background:
linear-gradient(to right, blue, transparent),
url(https://grainy-gradients.vercel.app/noise.svg);
filter: contrast(170%) brightness(1000%);
}
Adjusting the two values controls how far the muddled grays are pushed out. Zooming in reveals another wrinkle: the SVG filter output was colorful to begin with, and boosting brightness and contrast emphasizes particular hues, so the noise is made up of many colors rather than a uniform one. This confetti effect is barely perceptible, but when it is unwanted, CSS blending can filter the colors further.


Blending two-color gradients
For a grain gradient that transitions between two colors, CSS blending stacks color layers. An extra <div> is positioned over the original gradient and given mix-blend-mode: multiply; to smooth the result.
<section>
<div class="isolate">
<div class="noise"></div>
<div class="overlay"></div>
</div>
</section>
.noise {
/* ... */
background:
linear-gradient(20deg, rebeccapurple, transparent),
url(https://grainy-gradients.vercel.app/noise.svg);
contrast(170%) brightness(1000%);
}
.overlay {
/* ... */
background: moccasin;
mix-blend-mode: multiply;
}
The isolation property creates a new stacking context and limits what gets blended. Without it, the gradient and overlay would also blend with the background color.
/* Same as before */
.isolate {
isolation: isolate;
/* ... */
}
Where it fits
- Light and shadow: gradients occur naturally in lighting, and
mix-blend-modecan blend them and selectively filter which noise colors show. A dark gradient gives the shadow version; inverting it gives the light version. - Holographic foil: a drastic brightness and contrast boost produces a rainbow effect resembling holographic foil.
Extending the technique
- Swap the SVG: the examples share one SVG, but the parameters that generate the noise can be tuned for coarseness and character in the playground.
- Try other gradients: CSS offers five types of gradients in total;
linear-gradientis only the start, and the others includerepeating-conic-gradient. - Stack more layers: CSS blending handles arbitrarily many layers blended down together.
- Apply other SVG filters: Gaussian blur and different lighting types are available, and they can be referenced from a CSS filter and applied to any HTML element, not just SVG.
Browser support
All modern browsers support the core of the technique; Internet Explorer does not. IE does support SVG as a CSS background image, but not the CSS filter property. Browser data below is from Caniuse, where a number indicates support at that version and up.
SVG as a CSS background image
Desktop
| Chrome | Firefox | IE | Edge | Safari |
|---|---|---|---|---|
| 5 | 24 | 9 | 16 | 5 |
Mobile / Tablet
| Android Chrome | Android Firefox | Android | iOS Safari |
|---|---|---|---|
| 157 | 160 | 3 | 4.2-4.3 |
CSS filter effects
Desktop
| Chrome | Firefox | IE | Edge | Safari |
|---|---|---|---|---|
| 18* | 35 | No | 79 | 6* |
Mobile / Tablet
| Android Chrome | Android Firefox | Android | iOS Safari |
|---|---|---|---|
| 157 | 160 | 4.4* | 6.0-6.1* |
One caveat reported from testing: Blink-based browsers such as Chrome and WebKit-based ones such as Safari implement mix-blend-mode slightly differently. If CSS blending is part of the design, test across browsers; browser-specific media queries can be used to reconcile the visual differences with small CSS tweaks.



