codegurukool.com · Free coding tutorials & online compiler

Home › CSS Tutorial › CSS image filters

CSS image filters

Blur, grayscale and more.

filter accepts blur(), grayscale(), brightness(), contrast(), hue-rotate() and drop-shadow().

Commands in this lesson

filter

Definition: Builds a new array with only the items that pass a test.

Syntax:

array.filter(function);

Example:

console.log([1, 2, 3, 4].filter(function(x){ return x % 2 === 0; }));

Example code

<style>div{width:90px;height:60px;display:inline-block;margin:6px;background:linear-gradient(135deg,#e4572e,#2e86de)}</style>
<div></div><div style='filter:grayscale(1)'></div><div style='filter:blur(3px)'></div><div style='filter:hue-rotate(120deg)'></div>

Run this code in the online editor

← CSS tooltipsobject-fit and position →