Filter Functions for Visual Effects
You'll learn how to apply live graphical effects like blur, brightness, contrast, and shadows to any HTML element using CSS filter functions.
The Core Idea
Filter functions let you modify an element's visual appearance without touching the original image or content. Think of them like Instagram filters for your website—you're applying effects on top of what's already there. These effects happen in real-time in the browser and work on any HTML element, from images to entire sections.
Common Filter Functions
The filter property accepts one or more functions:
blur() - Adds a Gaussian blur effect
.soft-focus {
filter: blur(5px);
}
brightness() - Adjusts luminosity (1 is normal, >1 is brighter, <1 is darker)
.dimmed {
filter: brightness(0.7);
}
contrast() - Increases or decreases contrast (1 is normal)
.punchy {
filter: contrast(1.5);
}
drop-shadow() - Creates a shadow that follows the element's shape (unlike box-shadow)
.floating {
filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}
Combining Multiple Filters
You can chain filters together with spaces:
.vintage-photo {
filter: brightness(0.9) contrast(1.2) blur(0.5px);
}
Filters apply in the order you write them, so order can matter for the final result.
Key Takeaway: Filter functions provide powerful visual effects directly in CSS—use blur(), brightness(), contrast(), and drop-shadow() to transform how elements appear without modifying the source content.