Skip to main content
Syllabus
On this page

CSS Filters & backdrop-filter (Glassmorphism)

Badar KhalilUpdated September 29, 2026 6 min read

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

FunctionWhat it doesExample
blur()Gaussian blur; takes a lengthblur(4px)
brightness()Lightens or darkens; 1 is normalbrightness(1.2)
contrast()Changes contrast; 1 is normalcontrast(150%)
grayscale()Removes color; 0 to 1grayscale(1)
sepia()Warm vintage tonesepia(.8)
saturate()Boosts or reduces color intensitysaturate(1.8)
hue-rotate()Rotates hue on the color wheelhue-rotate(90deg)
invert()Inverts colors; 0 to 1invert(1)
opacity()Transparency as a filteropacity(.5)
drop-shadow()Shadow following the visible shapedrop-shadow(0 4px 6px rgb(0 0 0 / 30%))
url()Reference an SVG filterurl(#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.

Code
.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

  1. Place a colorful, detailed background behind the card (gradient, image or blobs). A plain white background hides the effect.
  2. Give the card a translucent background: rgb(255 255 255 / 10-25%).
  3. Add backdrop-filter: blur(10px to 20px), optionally with saturate(150%) to keep colors lively.
  4. Add a thin light border (1px solid rgb(255 255 255 / 30%)) to imitate the edge of glass.
  5. Add a soft shadow for depth: 0 8px 32px rgb(0 0 0 / 20%).
  6. Check text contrast carefully.

6. filter vs backdrop-filter

filterbackdrop-filter
AffectsThe element and its childrenContent behind the element
Needs transparencyNoYes (translucent background)
Creates stacking contextYesYes
Typical useImage effects, disabled statesFrosted 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:

Code
.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-filter elements 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 and box-shadow for boxes.
  • Animate filter values with transitions on small elements only.

Common Mistakes

  • Using backdrop-filter with 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.

Try it Yourself HTML
Output

Press Run to execute.

Try it Yourself HTML
Output

Press Run to execute.

Try it Yourself HTML
Output

Press Run to execute.

Try it Yourself HTML
Output

Press Run to execute.

Try it Yourself HTML
Output

Press Run to execute.

Exercise: Build a Glassmorphism CardHTML

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.

Try it Yourself HTML
Output

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.

Exercise: Grayscale Image Gallery HoverHTML

Make every .thumb grayscale by default. On hover, remove the grayscale, slightly increase brightness and add a smooth 0.3s transition.

Try it Yourself HTML
Output

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.

Quiz: Filters & Glassmorphism Quiz Pass 70%
Loading quiz…

Was this page helpful?