CSS contrast() Function
contrast() function to adjust the contrast of an image.
contrast() function is used with the
filter property to adjust the contrast of an image.
contrast() function requires an argument to be passed to it. This argument determines the contrast level that's applied to the image. The argument can be either a percentage value or a number.
Here's an example using a percentage value to give the image more contrast:
Here's an example using a percentage value to give the image less contrast:
Here's an example using a number:
The official syntax of the
contrast() function is as follows:
contrast() = contrast( [ <number> | <percentage> ] )
contrast() function accepts a
<percentage> as its argument. This argument determines the contrast level of the image.
A value of
0% results in an image that's completely gray. A value of
100% results in an image that's unchanged. Any amount over
100% produces more contrast.
<number> value of
0.5 has the same effect as the
50%. A value of
1 is the same as
Negative values are not allowed.
The following table provided by Caniuse.com shows the level of browser support for this feature.