On this page
CSS Filters & backdrop-filter (Glassmorphism)
What Are CSS Filters and backdrop-filter?
The CSS filter property applies graphical effects, such as blur or color shifts, to an element and everything inside it. The backdrop-filter property applies those effects to the area behind an element, which is the secret of the popular glassmorphism (frosted glass) design style. Our focus keyword is CSS filters, and this lesson also covers trending searches: glassmorphism CSS, backdrop-filter blur, CSS grayscale hover effect, frosted glass navbar, drop-shadow filter, CSS image effects, and filter performance.
1. The filter Property and Its Functions
| Function | What it does | Example |
|---|---|---|
blur() | Gaussian blur; takes a length | blur(4px) |
brightness() | Lightens or darkens; 1 is normal | brightness(1.2) |
contrast() | Changes contrast; 1 is normal | contrast(150%) |
grayscale() | Removes color; 0 to 1 | grayscale(1) |
sepia() | Warm vintage tone | sepia(.8) |
saturate() | Boosts or reduces color intensity | saturate(1.8) |
hue-rotate() | Rotates hue on the color wheel | hue-rotate(90deg) |
invert() | Inverts colors; 0 to 1 | invert(1) |
opacity() | Transparency as a filter | opacity(.5) |
drop-shadow() | Shadow following the visible shape | drop-shadow(0 4px 6px rgb(0 0 0 / 30%)) |
url() | Reference an SVG filter | url(#noise) |
2. Chaining Filters
Separate several functions with spaces: filter: grayscale(.6) contrast(1.1) brightness(1.05);. Order matters, because each function is applied to the result of the previous one. filter: none removes all filters.
3. Common Filter Use Cases
- Hover effects: grayscale images that turn colorful on hover.
- Disabled states:
grayscale(1) opacity(.6). - Dark mode images: slightly lower brightness or contrast for photos.
- Icons:
invert(1)to switch black icons to white. - Blurring content: hide sensitive information, or blur the page behind a modal.
- Shapes with transparency:
drop-shadow()on PNG, SVG or clipped elements.
4. What Is backdrop-filter?
backdrop-filter uses the same functions as filter, but applies them to everything visible behind the element, within the element's border box (rounded corners are respected). The element itself, and its text, stay sharp. For the effect to be visible, the element must have a semi-transparent background.
.glass {
background: rgb(255 255 255 / 15%);
-webkit-backdrop-filter: blur(12px) saturate(160%);
backdrop-filter: blur(12px) saturate(160%);
border: 1px solid rgb(255 255 255 / 30%);
border-radius: 16px;
}5. Glassmorphism Recipe
- Place a colorful, detailed background behind the card (gradient, image or blobs). A plain white background hides the effect.
- Give the card a translucent background:
rgb(255 255 255 / 10-25%). - Add
backdrop-filter: blur(10px to 20px), optionally withsaturate(150%)to keep colors lively. - Add a thin light border (
1px solid rgb(255 255 255 / 30%)) to imitate the edge of glass. - Add a soft shadow for depth:
0 8px 32px rgb(0 0 0 / 20%). - Check text contrast carefully.
6. filter vs backdrop-filter
| filter | backdrop-filter | |
|---|---|---|
| Affects | The element and its children | Content behind the element |
| Needs transparency | No | Yes (translucent background) |
| Creates stacking context | Yes | Yes |
| Typical use | Image effects, disabled states | Frosted glass navbars, modals, cards |
7. Browser Support and Fallbacks
filter is supported everywhere. backdrop-filter works in all current major browsers, though older Safari versions need the -webkit-backdrop-filter prefix, so include both. Provide a fallback with @supports:
.glass { background: rgb(15 23 42 / 90%); }
@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
.glass { background: rgb(255 255 255 / 15%); backdrop-filter: blur(12px); }
}8. Performance
- Blur is GPU heavy. Large blur radii on big areas can drop frame rates, especially on mobile and while scrolling.
- Keep
backdrop-filterelements small (navbars, cards) and avoid stacking many of them. - Do not animate blur radius on large elements. Fade opacity instead.
- Fixed or sticky elements with backdrop-filter are fine, but test scrolling on real devices.
9. Accessibility
- Glass cards sit over changing backgrounds, so text contrast can drop. Use a slightly darker translucent tint or add a solid fallback behind text.
- Respect users who prefer less transparency:
@media (prefers-reduced-transparency: reduce)can switch to a solid background where supported. - Do not use blur to hide information that must stay private, since it is only visual.
Best Practices
- Use subtle values: blur 8 to 16px, background alpha 10 to 25%.
- Always add the
-webkit-prefixed backdrop-filter. - Use
drop-shadow()for non-rectangular shapes andbox-shadowfor boxes. - Animate filter values with transitions on small elements only.
Common Mistakes
- Using
backdrop-filterwith a solid opaque background, so nothing is visible. - Expecting
filter: blur()to blur only the background. It blurs the element and its text. - Forgetting that a filter creates a new stacking context and containing block for fixed-position children.
- Applying heavy filters to many elements at once.
Summary
CSS filters transform how elements look, from grayscale hovers to drop-shadows, and backdrop-filter blurs what lies behind an element to create glassmorphism. Combine a translucent background, blur, a thin border and a soft shadow, keep it light for performance, and check contrast. Explore the examples below.
Press Run to execute.
Press Run to execute.
Press Run to execute.
Press Run to execute.
Press Run to execute.
Style .glass so it looks like frosted glass: translucent white background (about 15%), backdrop-filter blur of 12px with the -webkit- prefix, a 1px semi-transparent white border, 16px radius and a soft shadow. The card sits over a colorful gradient background.
Press Run to execute.
Show expected output
A translucent, blurred card with a light border over the colorful background.This is a self-check — compare your result with the expected output above.
Make every .thumb grayscale by default. On hover, remove the grayscale, slightly increase brightness and add a smooth 0.3s transition.
Press Run to execute.
Show expected output
Gray thumbnails that turn colorful and brighter on hover.This is a self-check — compare your result with the expected output above.
Was this page helpful?