Full answer
These three properties change how pixels are drawn.
filter applies effects to the element itself and everything inside it: blur(), grayscale(), brightness(), contrast(), drop-shadow() and others, often chained. drop-shadow() follows the shape of the drawn pixels, so it works on a transparent PNG or an SVG shape, while box-shadow always shadows the rectangle.
backdrop-filter applies the effect to whatever is behind the element, seen through its semi-transparent background. The "frosted glass" look is backdrop-filter: blur(8px) plus a translucent background colour. It needs the element's own background to be at least partly transparent, or nothing shows.
mix-blend-mode blends the element's colours with what is behind it, with modes such as multiply, screen and overlay. A common use is multiply for a logo that should look printed on a coloured photo.
Side effects to remember:
- A
filter(other thannone),backdrop-filterormix-blend-modecreates a stacking context. - A
filteralso makes the element the containing block for fixed and absolute descendants. Aposition: fixedchild of a filtered parent is positioned against that parent, not the viewport. - Large blurs are costly to draw, especially on phones and when animated. Test performance on real devices.
The glass panel blurs the gradient behind it. The image is shown in grey. The red square has position: fixed; top: 0; left: 0, yet it is drawn at the top-left corner of its filtered parent, which sits well below the top of the window, and not at the top of the window. That is the containing block effect.
Use filter for effects and opacity for plain fading, and keep an eye on contrast, because blur and blend modes can lower text legibility.
<style>
body { margin: 0; font-family: sans-serif; }
.photo { position: relative; height: 120px; background: linear-gradient(90deg, #f66, #6af); }
.glass { position: absolute; inset: 20px; padding: 12px; background: rgba(255, 255, 255, 0.35); backdrop-filter: blur(6px); }
.gray { filter: grayscale(100%); }
.multiply { mix-blend-mode: multiply; background: #ccc; padding: 8px; }
.wrap { margin-top: 100px; filter: blur(0px); }
.fixed-child { position: fixed; top: 0; left: 0; width: 40px; height: 40px; background: tomato; }
</style>
<div class="photo" id="photo"><div class="glass" id="glass">Frosted panel</div></div>
<img class="gray" id="img" alt="Campus" width="80" height="40" src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='40'%3E%3Crect width='80' height='40' fill='%23f66'/%3E%3C/svg%3E">
<div class="multiply" id="mul">Multiply</div>
<div class="wrap" id="wrap"><div class="fixed-child" id="fx"></div></div>Run in Chrome 156 (headless) as a page; the snippet is wrapped in a minimal HTML document with doctype, charset and viewport meta tag. Two full runs gave identical results, and the measured values in the answer come from them.
Key points
- filter applies to the element and its children; backdrop-filter to what is behind it.
- drop-shadow follows drawn shapes; box-shadow follows the box.
- mix-blend-mode blends with the colors behind, for example multiply.
- filter and backdrop-filter create a stacking context; filter also contains fixed descendants.
- Large or animated blurs can be slow.
Common mistakes
- Applying filter to a parent of a fixed element and wondering why the fixed element no longer sticks to the viewport.
- Using backdrop-filter with an opaque background, so there is nothing to see through.
- Animating large blur values on many elements, which makes scrolling and animation slow.
Follow-ups
- What is the difference between filter: drop-shadow() and box-shadow?
- Why does a fixed child move with its filtered parent?
Tips
- Say that drop-shadow follows the shape of the pixels and box-shadow follows the box.
- Name the stacking context and containing block side effects. They are the real-world bugs.