D DevBrainBox

CSS Filters

CSS

What is filter in CSS?

The filter property lets you apply graphic effects to elements, similar to Instagram filters — no image editing software needed.

It can be applied to:

  • Images
  • Videos
  • Text
  • Backgrounds
  • Any HTML element

Common Filter Functions

FilterWhat it doesExample
blur(px)Adds a blurfilter: blur(5px);
brightness(%)Adjusts brightness (100% = normal)filter: brightness(150%);
contrast(%)Changes contrastfilter: contrast(120%);
grayscale(%)Converts to black & whitefilter: grayscale(100%);
sepia(%)Applies warm brownish tonesfilter: sepia(100%);
saturate(%)Boosts or reduces colorsfilter: saturate(200%);
invert(%)Inverts colors (like a negative)filter: invert(100%);
hue-rotate(deg)Shifts colors around the color wheelfilter: hue-rotate(180deg);
drop-shadow()Adds shadow like box-shadowfilter: drop-shadow(5px 5px 5px gray);

Example

img {
  width: 300px;
  filter: grayscale(100%) blur(2px);
}

This will make the image black and white with a soft blur.

Another Example: Hover Effect

img:hover {
  filter: brightness(120%) contrast(110%);
}

The image becomes brighter and more vivid when hovered.

Apply Filters to Any Element

.card {
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.2));
}

Adds a soft shadow to a card.

FeatureUse For
blurSoftening images or backgrounds
grayscaleBlack & white effects
brightnessLight/dark adjustments
hue-rotateCreative color changes
drop-shadowStylish shadows

On this page