CSS filter Property
CSS filter Property
CSS filter
property applies visual effects to an element.
Note: Filters are commonly used to adjust the rendering of images, backgrounds, and borders.
Example
Syntax
Using CSS
Using Javascript
Animatable
Yes, filter property is animatable. CSS Animatable Properties Reference.
Default Value
Default value for CSS filter property is none.
Property Value
The following table provides a list of values for CSS filter
property.
Value | Explanation |
---|---|
none | Specifies no effects. |
blur | Applies a blur effect to the image. The value should be in px. For example, blur(5px). |
brightness | Adjusts the brightness of the image. The value should be in % and should not be in negative. For example, brightness(200%) |
contrast | Adjusts the contrast of the image. The value should be in % and should not be in negative. For example, contrast(200%) |
drop-shadow | Applies a drop shadow effect to the image. The value should be in the order of drop-shadow(h-shadow v-shadow blur spread color). For example, drop-shadow(3px 6px 5px #8c8c8c) Here some of the parameters are optional h-shadow - Required v-shadow - Required blur - Optional spread - Optional color - Optional |
grayscale | Converts the image to grayscale. The value should be in % and should not be in negative. For example, grayscale(100%). |
hue-rotate | Applies a hue rotation on the image. The value should be in deg (degree) and should not exceed 360deg. For example, grayscale(255deg). |
invert | Inverts the samples in the image. The value should be in % and should not be in negative. For example, invert(100%). |
opacity | Sets the opacity level for the image. The value should be in % and should not be in negative. For example, opacity(100%). |
saturate | Saturates the image. The value should be in % and should not be in negative. For example, opacity(100%). Negative values are not allowed. |
sepia | Converts the image to sepia. The value should be in % and should not be in negative. For example, sepia(100%). |
All in One
In the following example, we will demonstrate all values of CSS filter
property.
Example
Using JavaScript
In the following example, we will demonstrate how to change the CSS filter
property of an element using JavaScript.
Example
Reminder
Hi Developers, we almost covered 98.7% of CSS Tutorials with examples for quick and easy learning.
We are working to cover every Single Concept in CSS.
Please do google search for:
Join Our Channel
Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.
This channel is primarily useful for Full Stack Web Developer.