- Tags: Image
- Categories: CSS Properties, CSS Reference, Reference
Quick Reference
The filter property defines visual effects (like blur and saturation) to an image element.
img {
filter: sepia(100%);
}
Values
Default value | none |
Inherited values | no |
Can it be animated? | yes |
These are the allowed values.
Filter | Description |
---|---|
none | Specifies no effects (default) |
blur(px) | Applies a blur effect to the image; larger values mean more blur (0 is the default) |
brightness(%) | Adjusts the brightness of the image
|
contrast(%) | Adjusts the contrast of the image
|
drop-shadow(h-shadow v-shadow blur spread color) | Applies a drop shadow effect to the image
|
grayscale(%) | Converts the image to grayscale
|
hue-rotate(deg) | Applies a hue rotation on the image; the value defines the number of degrees around the color circle the image samples will be adjusted (0deg is default, and represents the original image) |
invert(%) | Inverts the samples in the image
|
opacity(%) | Sets the opacity level for the image. The opacity-level describes the transparency-level, where:
|
saturate(%) | Saturates the image.
|
sepia(%) | Converts the image to sepia.
|
url() | The url() function takes the location of an XML file that specifies an SVG filter, and may include an anchor to a specific filter element – for example: filter: url(svg-url#element-id) |
initial | Sets this property to its default value |
inherit | Inherits this property from its parent element |
Using JavaScript
The HTML element can also be styled using JavaScript and the element’s id.
document.getElementById('my_img').style.filter = 'sepia(100%)';
We’d like to acknowledge that we learned a great deal of our coding from W3Schools and TutorialsPoint, borrowing heavily from their teaching process and excellent code examples. We highly recommend both sites to deepen your experience, and further your coding journey. We’re just hitting the basics here at 1SMARTchicken.
Why 1SMARTchicken?
See More →
Thanks for your support!
CSS Books
All are affiliate links. Thank you for your support!
CSS NOTES:
- The “inherit”, “initial” and “unset” keywords can be used with any CSS property to set its value
- In CSS there are many ways to express a color value in a property
Feedback
If you see an error on the page or the code itself is incorrect or incomplete, or just plain wrong, please let us know. We’re always learning. NOTE: we do not sell your information and will not send you spam emails.