Filters and backdrop filters
Definition and purpose
A filter changes the rendered output of an element, including its contents. backdrop-filter operates on the rendered area behind the element within its applicable backdrop. Neither is a layout sizing property.
Order changes the pixels
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>CSS practice</title> <style> body { margin: 0; font: 16px sans-serif; color: #172033; background: white; } #a { width: 100px; height: 80px; background: red; } #a { filter: brightness(0) invert(1); } </style> </head> <body> <div id="a" aria-hidden="true"></div> </body></html>Black is inverted to white; reversing these functions gives black. The box stays 100px wide.
Syntax and mental model
Filter functions run in the specified order; brightness(0) turns opaque colors black, while invert(1) reverses channel values. Blur samples neighbors and can extend the visual effect outside the original box; clipping and filter regions can limit this. A backdrop effect needs some transparency in the foreground for the result to be visible. A non-none filter can create a stacking context and a containing block for positioned descendants. Prefer a readable solid or translucent surface as a fallback, and verify contrast over varied backgrounds.
Blur behind a panel
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>CSS practice</title> <style> body { margin: 0; font: 16px sans-serif; color: #172033; background: white; } #b { background: linear-gradient(90deg, navy, white); padding: 20px; } #a { margin: 0; padding: 12px; color: black; background: rgb(255 255 255 / .9); backdrop-filter: blur(6px); } </style> </head> <body> <section id="b"> <p id="a">Readable panel</p> </section> </body></html>The text itself is not filtered. The mostly opaque panel is the fallback; verify real contrast separately.
Common mistakes
Do not apply blur to an entire text panel when only the backdrop should be blurred. Do not infer contrast from the filter string or assume GPU acceleration.
Practice and next steps
After trying the examples, complete the linked coding exercise and review questions. Predict the result before running your code. Prerequisite: Image functions and object positioning. Next lesson: Blending and isolation.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Filters and backdrop filters — knowledge check
Five questions on filters and backdrop filters.
What does filter affect?
Why can filter order matter?
Which property targets the area behind a panel?
What can limit an extended blur?
How should contrast be verified?