{"id":102,"date":"2026-10-18T17:53:13","date_gmt":"2026-10-18T17:53:13","guid":{"rendered":"https:\/\/refracttools.com\/blog\/?p=102"},"modified":"2026-10-18T17:53:13","modified_gmt":"2026-10-18T17:53:13","slug":"css-grain-texture","status":"publish","type":"post","link":"https:\/\/refracttools.com\/blog\/css-techniques\/css-grain-texture\/","title":{"rendered":"Adding grain and noise texture to CSS gradients"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">To add grain to a CSS gradient, generate noise with an SVG <code>feTurbulence<\/code> filter, embed it as a data URI, and lay it over the gradient on a <code>::after<\/code> pseudo-element with <code>mix-blend-mode: overlay<\/code> or <code>soft-light<\/code> 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.<\/p>\n\n\n\n<div class=\"wp-block-group is-style-refract-takeaways is-layout-constrained wp-block-group-is-layout-constrained\">\n<h3 class=\"wp-block-heading\">Key takeaways<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>SVG&#8217;s <code>feTurbulence<\/code> filter draws noise mathematically, so a tiny data URI can texture a full-screen background.<\/li>\n\n\n<li>Put the grain on a pseudo-element with <code>z-index: -1<\/code> and <code>isolation: isolate<\/code> on the parent, so text stays crisp on top.<\/li>\n\n\n<li><code>overlay<\/code> and <code>soft-light<\/code> keep colours rich; keep opacity low, around 0.15 to 0.4.<\/li>\n\n\n<li>Grain breaks up the visible steps (banding) that appear in smooth gradients on some screens.<\/li>\n<\/ul>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Why add grain to a gradient?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">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&#8217;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.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How do you add grain in CSS?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">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:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.grainy {\n  position: relative;\n  isolation: isolate;\n  background: linear-gradient(135deg, #ff7a59, #7b5cff);\n}\n\n.grainy::after {\n  content: \"\";\n  position: absolute;\n  inset: 0;\n  z-index: -1;\n  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\");\n  mix-blend-mode: overlay;\n  opacity: .35;\n  pointer-events: none;\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">What each part does<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><code>isolation: isolate<\/code><\/strong> creates a new stacking context, so the <code>z-index: -1<\/code> pseudo-element sits above the parent&#8217;s background but below its text and children.<\/li>\n\n\n<li><strong><code>type=\"fractalNoise\"<\/code><\/strong> gives soft, even grain. <code>turbulence<\/code> gives a streakier, more liquid pattern.<\/li>\n\n\n<li><strong><code>baseFrequency<\/code><\/strong> sets the grain size. Higher numbers give finer speckles; around 0.6 to 0.9 looks like film grain.<\/li>\n\n\n<li><strong><code>numOctaves<\/code><\/strong> adds layers of finer detail. Two to four is plenty; more costs rendering time for little visible change.<\/li>\n\n\n<li><strong><code>stitchTiles=\"stitch\"<\/code><\/strong> makes the edges of the tile line up, so there are no visible seams when it repeats.<\/li>\n\n\n<li><strong><code>pointer-events: none<\/code><\/strong> stops the overlay from catching clicks.<\/li>\n<\/ul>\n\n\n<aside class=\"tool-card tool-card--inline\"><span class=\"swatch\" style=\"background:linear-gradient(135deg,#ff8a5c,#5c7cff)\" aria-hidden=\"true\"><\/span><div class=\"tool-card__body\"><p class=\"tool-card__eyebrow\">Free tool<\/p><p class=\"tool-card__name\">Grain and noise texture generator<\/p><p class=\"tool-card__blurb\">Film grain and noise for gradients, from a tiny SVG filter.<\/p><\/div><a class=\"btn primary\" href=\"https:\/\/refracttools.com\/noise-texture-generator\/\">Try it free <span aria-hidden=\"true\">\u2192<\/span><\/a><\/aside>\n\n\n\n<h2 class=\"wp-block-heading\">Which blend mode should you use for grain?<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><div class=\"table-scroll\" tabindex=\"0\" role=\"region\" aria-label=\"Scrollable table\"><table><thead><tr><th>Blend mode<\/th><th>Effect<\/th><th>Good for<\/th><\/tr><\/thead><tbody><tr><td><code>overlay<\/code><\/td><td>Adds texture to lights and darks, boosts contrast slightly<\/td><td>Bold, saturated gradients<\/td><\/tr><tr><td><code>soft-light<\/code><\/td><td>Gentler version of overlay<\/td><td>Pastel and subtle backgrounds<\/td><\/tr><tr><td><code>multiply<\/code><\/td><td>Darkens; grain shows as dark specks<\/td><td>Light backgrounds, a paper feel<\/td><\/tr><tr><td><code>screen<\/code><\/td><td>Lightens; grain shows as light specks<\/td><td>Dark backgrounds, a starry or dusty feel<\/td><\/tr><tr><td><code>normal<\/code><\/td><td>No blending, just grey noise on top<\/td><td>Rarely; it tends to wash colours out<\/td><\/tr><\/tbody><\/table><\/div><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Does grain fix gradient banding?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">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&#8217;t need much: an opacity of 0.1 to 0.2 is usually enough to hide banding without the texture becoming a visible style.<\/p>\n\n\n\n<div class=\"wp-block-group is-style-refract-callout is-layout-constrained wp-block-group-is-layout-constrained\">\n<p class=\"wp-block-paragraph\"><strong>Pairing:<\/strong> Grain pairs especially well with <a href=\"\/blog\/css-techniques\/css-mesh-gradient\/\">CSS mesh gradients<\/a>, which have large soft areas where banding is most likely.<\/p>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Is CSS grain bad for performance?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">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:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Animating the grain<\/strong> 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.<\/li>\n\n\n<li><strong>Stacking it on dozens of elements.<\/strong> Apply it to the few large surfaces that need it, such as the hero and section backgrounds, rather than to every card.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Can you add grain to photos or text?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Yes. The same pseudo-element works over a photo or a <code>background-image<\/code>, 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 <a href=\"https:\/\/refracttools.com\/contrast-checker\/\">contrast checker<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Using grain in WordPress and page builders<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The generator&#8217;s &#8220;Paste into&#8221; 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 <code>selector<\/code>, so the grain only lands on the section you add it to.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Try it<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The <a href=\"https:\/\/refracttools.com\/noise-texture-generator\/\">Refract grain and noise texture generator<\/a> 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 <a href=\"https:\/\/refracttools.com\/css-gradient-generator\/\">CSS gradient generator<\/a> or the <a href=\"https:\/\/refracttools.com\/mesh-gradient-generator\/\">mesh gradient generator<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Last checked: October 2026.<\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Sources: <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/SVG\/Element\/feTurbulence\" rel=\"noopener\" target=\"_blank\">MDN: &lt;feTurbulence&gt;<\/a>, <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/mix-blend-mode\" rel=\"noopener\" target=\"_blank\">MDN: mix-blend-mode<\/a>, <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/isolation\" rel=\"noopener\" target=\"_blank\">MDN: isolation<\/a>.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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.<\/p>\n","protected":false},"author":1,"featured_media":101,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_refract_tool":"noise-texture-generator","footnotes":""},"categories":[8],"tags":[4,49,50],"class_list":["post-102","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-css-techniques","tag-css-generators","tag-gradients","tag-textures"],"_links":{"self":[{"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/posts\/102","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/comments?post=102"}],"version-history":[{"count":1,"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/posts\/102\/revisions"}],"predecessor-version":[{"id":110,"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/posts\/102\/revisions\/110"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/media\/101"}],"wp:attachment":[{"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/media?parent=102"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/categories?post=102"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/tags?post=102"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}