Filter Property
suggest changeSyntax
- filter: none (default value)
- filter: initial (defaults to none);
- filter: inherit (defaults to parent value);
- filter: blur(px)
- filter: brightness(number | %)
- filter: contrast(number | %)
- filter: drop-shadow(offset-x offset-y blur-radius color)
- filter: grayscale(number | %)
- filter: hue-rotate(deg)
- filter: invert(number | %)
- filter: opacity(number | %)
- filter: saturate(number | %)
- filter: sepia(number | %)
Parameters
Value | Description |
—— | —— |
| Function | Description |
|---|---|
blur(x) |
Blurs the image by x pixels. |
brightness(x) |
Values above 1 or 100% brighten the image. Lower values darken it. 1 leaves it unchanged. |
contrast(x) |
Values above 1 or 100% increase contrast. Lower values decrease contrast. This is not the same as saturation. |
drop-shadow(x y blur color) |
Draws a drop shadow that follows the alpha outline. Offsets may be negative. Blur and color are optional. There is no spread parameter; that exists on box-shadow, not drop-shadow(). |
grayscale(x) |
Converts the image toward gray. 1 or 100% is fully gray. The spelling is grayscale, not greyscale. |
hue-rotate(x) |
Rotates the hue by the given angle. |
invert(x) |
Inverts the colors. 1 or 100% is a full inversion. |
opacity(x) |
Sets the opacity of the filtered rendering. 1 or 100% is fully opaque. |
saturate(x) |
Values above 1 or 100% increase saturation. Lower values decrease it. |
sepia(x) |
Converts the image toward sepia. 1 or 100% is fully sepia. |
Remarks
- Write the standard unprefixed
filterproperty. A-webkit-prefix is only a legacy fallback, not the current spelling. - Prefer
box-shadowwhen you need a rectangular shadow, including spread. Usefilter: drop-shadow()when the shadow should follow a transparent image’s outline. Prefer theopacityproperty when you only need to fade an element, becausefilter: opacity()also creates a containing group. - In the CSSOM, set
element.style.filter.WebkitFilteris the legacy prefixed alias. - See MDN for the full function list.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents