CSSgrayscale() Function
Example
Set various grayscale for an image:
filter: grayscale(1);
}
#img2 {
filter: grayscale(60%);
}
#img3 {
filter: grayscale(0.4);
}
More "Try it Yourself" examples below.
Definition and Usage
The CSSgrayscale() filter function converts an image to grayscale.
- 100% (1) will make the image completely grayscale
- 0% (0) will have no effect
| Version: | CSS Filter Effects Module Level 1 |
|---|
Browser Support
The numbers in the table specify the first browser version that fully supports the function.
| Function | |||||
|---|---|---|---|---|---|
| grayscale() | 18 | 12 | 35 | 6 | 15 |
CSS Syntax
| Value | Description |
|---|---|
| amount | Optional. Specifies the grayscale as a number or percent. 100% (1) will make the element completely grayscale. 0% (0) represents the original image (no effect). Default value is 1. |
More Examples
Example
Use grayscale() with thebackdrop-filter property:
background-color: rgba(255, 255, 255, 0.4);
-webkit-backdrop-filter: grayscale(50%);
backdrop-filter: grayscale(50%);
padding: 20px;
margin: 30px;
font-weight: bold;
}
Related Pages
CSS reference:CSS filter property.
CSS reference:CSS blur() function.
CSS reference:CSS brightness() function.
CSS reference:CSS contrast() function.
CSS reference:CSS drop-shadow() function.
CSS reference:CSS hue-rotate() function.
CSS reference:CSS invert() function.
CSS reference:CSS opacity() function.
CSS reference:CSS saturate() function.
CSS reference:CSS sepia() function.

