Computer >> Computer tutorials >  >> Programming >> CSS

Working with CSS3 Filter Effects


To set Filter Effects in CSS3, use the filter property. Following filter effects can be set −

blur() | brightness() | contrast() | grayscale() | invert() | opacity() | saturate() | url();

Following is the code for using filter effects in CSS3 −

Example

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
img{
   margin: 20px;
   width: 200px;
   height: 200px;
}
img.normal{
   margin-left: 30%;
}
img.filter {
   filter: invert(100%);
}
</style>
</head>
<body>
<h1 style="text-align: center;">CSS3 Filter effect example</h1>
<img class="normal" src="https://i.picsum.photos/id/237/536/354.jpg">
<img class="filter" src="https://i.picsum.photos/id/237/536/354.jpg">
</body>
</html>

Output

The above code will produce the following output −

Working with CSS3 Filter Effects