Skip to content
Related Articles

Related Articles

CSS | grayscale() Function
  • Last Updated : 08 Aug, 2019

The grayscale() function is an inbuilt function which is used to apply a filter to the image to set the grayscale of the image.

Syntax:

grayscale( amount )

Parameters: This function accepts single parameter amount which holds the value of grayscale. The value of grayscale is set in terms of number and percentage. The value 0% represents original image while the value in between 0% to 100% represents the linear multipliers on the effect.

Below example illustrates the grayscale() function in CSS:

Example:




<!DOCTYPE html> 
<html
  
<head
    <title>CSS grayscale() Function</title
      
    <style>
        h1 {
            color:green;
        }
        body {
            text-align:center;
        }
        .grayscale_effect {
            filter: grayscale(100%);
        }
    </style>
</head
  
<body
    <h1>GeeksforGeeks</h1
      
    <h2>CSS grayscale() function</h2>
      
    <img class="grayscale_effect" src
        alt="GeeksforGeeks logo"
</body
  
</html>

Output:

Supported Browsers: The browsers supported by grayscale() function are listed below:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Safari
  • Opera
My Personal Notes arrow_drop_up