CSS
HTML
JavaScript
jQuery
PHP
SQL
WordPress
CSS 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.

FilterDescription
noneSpecifies 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
  • 0% will make the image completely black
  • 100% (1) is the default and represents the original image
  • Values over 100% will brighten the image
contrast(%)Adjusts the contrast of the image
  • 0% will make the image completely black
  • 100% (1) is the default and represents the original image
  • Values over 100% will give the image more contrast
drop-shadow(h-shadow v-shadow blur spread color)Applies a drop shadow effect to the image
  • h-shadow – Specifies a pixel value for the horizontal shadow; negative values place the shadow to the left of the image (required)
  • v-shadow – Specifies a pixel value for the vertical shadow; negative values place the shadow above the image (required)
  • blur – This is the third value and must be in pixels; adds a blur effect to the shadow; a larger value will create more blur; negative values are not allowed (0 is the default)
  • spread – This is the fourth value and must be in pixels; positive values will cause the shadow to expand and grow bigger; negative values will cause the shadow to shrink (0 is the default) (not all browsers support spread)
  • color – Adds a color to the shadow
grayscale(%)Converts the image to grayscale
  • 0% (0) is default and represents the original image
  • 100% will make the image completely gray (used for black and white images)
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
  • 0% is default and represents the original image
  • 100% will make the image completely inverted
opacity(%)Sets the opacity level for the image. The opacity-level describes the transparency-level, where:
  • 0% is completely transparent
  • 100% is default and represents the original image (no transparency)
saturate(%)Saturates the image.
  • 0% will make the image completely un-saturated
  • 100% is default and represents the original image
  • Values over 100% provides super-saturated results
sepia(%)Converts the image to sepia.
  • 0% is default and represents the original image
  • 100% will make the image completely 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)
initialSets this property to its default value
inheritInherits 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%)';
				
			
				
					<button onclick='my_function()'>Click Here</button>

<script>
function my_function() {
    document.getElementById('my_img').style.filter = 'sepia(100%)';
}
</script>
				
			

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.

CSS
HTML
JavaScript
jQuery
PHP
SQL
WordPress

Why 1SMARTchicken?

This site was built and is maintained to benefit my autistic son.
See More →

My Son's Name is Johnny

He was diagnosed as autistic quite late, at age four...
His story

Buy Me a Coffee

Thanks for your support!

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.