HTML Element Style How to - Gray out images








Question

We would like to know how to gray out images.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
img {<!--  w ww .j a v  a 2  s . c o  m-->
  -webkit-filter: grayscale(100%);
}
</style>
</head>
<body>
  <img src="http://www.java2s.com/style/download.png">
</body>
</html>

The code above is rendered as follows: