How it works
Ink that soaks into the paper
Real ink doesn't stop at the edge of the pen stroke: it runs along the paper fibers, spreads while it is wet and leaves more pigment where the water dried last. Each of those becomes one or two SVG filter primitives, applied to ordinary shapes and text.
1. Wandering edges: feTurbulence + feDisplacementMap
<feTurbulence type="fractalNoise"> is the paper's fiber structure, with Fiber size as the inverse of its baseFrequency. <feDisplacementMap> then moves every pixel of the content by scale × (C − 0.5), with C the noise's red channel for x and green for y. The
noise almost never leaves 0.23–0.77 (measured in Chromium), so a Bleed of
10 px shifts pixels by up to about 2.7 px.
Inside a flat shape that changes nothing (every neighbor has the same color); along the edges
it pulls the outline into irregular bays and spikes.
2. A wet edge: blur, then a soft threshold
The displaced edge is still pixel-sharp and a bit noisy. feGaussianBlur spreads
it out like wet ink, and an feColorMatrix alpha row turns the blur back into an
edge: A′ = A / softness + (0.5 − threshold / softness), clamped to 0–1. That is the
same trick as the gooey effect, only with a soft ramp
instead of a hard one: the edge sits where the blurred alpha equals the Threshold,
and Softness is how much of the blur survives as feathering. Lower thresholds let the ink
spread further; neighboring strokes run together the way wet ink does.
The ramp is never allowed to start below alpha 0 (the softness is capped at twice the threshold). Otherwise the matrix would give every transparent pixel a little opacity, and since transparent pixels are black, the whole element would get a grey veil.
3. Watercolor: pigment pooling
When a wash dries, the water at its edge evaporates first and pulls pigment outwards, so a dried wash is pale in the middle with a darker rim. The filter rebuilds that in three steps:
- Denser color.
feBlend mode="multiply"of the ink with itself gives c × c per channel: the same hue, darker and more saturated, like a thicker layer of the same pigment. - Where the rim is. Blurring the ink by the Rim width leaves alpha
near 1 deep inside a shape and about 0.5 on its edge. A color matrix turns that into a
white mask with alpha
2·(1 − A): 0 in the middle, 1 at the edge. - Mix.
feComposite operator="arithmetic" k1="pool"multiplies the dense color with the mask, and that rim goesoverthe wash, whose alpha is lowered to 1 at the current pooling (the pigment that went to the rim is missing from the middle).
4. Granulation and paper
Some pigments settle into the valleys of the paper and look speckled. A second, fine feTurbulence becomes a white mask whose alpha runs from 1 − granulation to 1, and the ink is multiplied with it. Density finally scales the ink's alpha with feFuncA type="linear".
<svg width="0" height="0" aria-hidden="true">
<!-- region: 12px around the element, as a fraction of its size -->
<filter id="ink-bleed" x="…" y="…" width="…" height="…"
color-interpolation-filters="sRGB">
<feTurbulence type="fractalNoise" baseFrequency="0.0556"
numOctaves="4" seed="2" result="fibers" />
<feDisplacementMap in="SourceGraphic" in2="fibers" scale="10"
xChannelSelector="R" yChannelSelector="G" result="bled" />
<feGaussianBlur in="bled" stdDeviation="1.5" result="wet" />
<feColorMatrix in="wet" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 5 -2"
result="ink" />
<feOffset in="ink" result="pigment" />
<feTurbulence type="fractalNoise" baseFrequency="0.3333"
numOctaves="2" seed="3" />
<feColorMatrix values="0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.3704 0.7148"
result="granules" />
<feComposite in="pigment" in2="granules" operator="arithmetic" k1="1"
result="settled" />
<feComponentTransfer in="settled">
<feFuncA type="linear" slope="1" />
</feComponentTransfer>
</filter>
</svg> The paper is a separate layer behind the content: its color, plus a high-frequency noise lit
by <feDiffuseLighting> (the noise becomes a height map, and a distant light
rakes across it) and multiplied on top. The ink layer is multiplied onto the paper too, so the
fiber texture shows through the color instead of the ink sitting on top like a sticker.
<!-- full-size, behind the ink, on a paper-colored background -->
<filter id="paper" x="0" y="0" width="100%" height="100%">
<feTurbulence type="fractalNoise" baseFrequency="0.9 0.6" numOctaves="3" />
<feDiffuseLighting surfaceScale="1.6" diffuseConstant="1.05" lighting-color="#fff">
<feDistantLight azimuth="235" elevation="58" />
</feDiffuseLighting>
</filter>
.paper-texture { mix-blend-mode: multiply; opacity: 0.35; }
.ink { filter: url(#ink-bleed); mix-blend-mode: multiply; } Text
- The heading on the stage is real HTML text: you can select and copy it, and screen readers read it as usual. Only its rendering is filtered.
- The bleed is in px, not relative to the font size. What frays a 5rem heading nicely makes body text unreadable; for running text, keep Bleed at 2–3 px and the blur below 1 px, or apply the effect only to headings and illustrations.
- Displacement, granulation and the paper texture all lower contrast. Check the result against WCAG if the text carries information, not only decoration.
Browser support and performance
Every primitive here is part of SVG filters, Baseline widely available (webstatus.dev), and filter: url(#id) on HTML works in all current engines. Checked in Chromium only;
Firefox and Safari are untested.
- For static content the browser renders the filter once and caches it. Anything that changes inside (a hover color, an animation, a caret) makes it rerun over the whole element, and with two turbulences, three blurs and several composites it is one of the heavier filters in this collection. Keep it to illustrations and headings rather than whole pages.
- The filter region grows with the bleed and blur (12 px on each side right now), so ink can run past the element's box without being cut off. The component measures the element to express that padding as a fraction of its size.
- The paper texture is a full-size lit turbulence. It only renders once, but on a very large stage, a pre-rendered paper image is cheaper.