CSS Image Filters


🔹 What are CSS Image Filters?

CSS Image Filters are visual effects applied to images (or other elements) using the filter property. They allow you to adjust colors, blur, brightness, contrast, and more, directly in CSS without editing the image itself.


🔸 Common CSS Filter Functions

Filter Function Description Example
blur(px) Applies blur effect filter: blur(5px);
brightness(%) Adjusts brightness (0% = black) filter: brightness(150%);
contrast(%) Adjusts contrast (100% = default) filter: contrast(200%);
grayscale(%) Converts to grayscale (100% = full gray) filter: grayscale(100%);
invert(%) Inverts colors (100% = full inversion) filter: invert(100%);
opacity(%) Sets opacity level filter: opacity(50%);
saturate(%) Adjusts saturation filter: saturate(200%);
sepia(%) Applies sepia tone filter: sepia(80%);
drop-shadow(offsetX offsetY blurRadius color) Adds shadow filter: drop-shadow(5px 5px 5px black);

🔸 Example: Multiple Filters Combined

img {
  filter: grayscale(50%) blur(2px) brightness(120%);
}

🔸 Using Filters with Transitions

img {
  transition: filter 0.5s ease;
}

img:hover {
  filter: brightness(150%) saturate(120%);
}

Practice Questions

Q1. Apply a 5px blur to all images.

Q2. Make images grayscale on hover.

Q3. Increase brightness to 120% on hover.

Q4. Add a drop shadow of 4px offset with black color.

Q5. Invert colors of an image completely.

Q6. Set image opacity to 60%.

Q7. Apply a sepia tone of 70%.

Q8. Saturate an image to 200% when hovered.

Q9. Combine grayscale and blur effects on images.

Q10. Use transition to animate filter changes smoothly.


Go Back Top