Following is the code to create a black and white image with CSS −
Example
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
img{
margin: 20px;
}
img.normal{
margin-left: 30%;
width: 300px;
height: 300px;
}
img.filter {
width: 300px;
height: 300px;
filter: grayscale(100%);
}
</style>
</head>
<body>
<h1 style="text-align: center;">CSS Black and White Image example</h1>
<img class="normal" src="https://i.picsum.photos/id/59/500/500.jpg">
<img class="filter" src="https://i.picsum.photos/id/59/500/500.jpg">
</body>
</html>Output
The above code will produce the following output −
