Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

CSS Tutorial

CSS HOME CSS Introduction CSS Syntax CSS Selectors CSS How To CSS Comments CSS Colors CSS Backgrounds CSS Borders CSS Margins CSS Padding CSS Height/Width CSS Box Model CSS Outline CSS Text CSS Fonts CSS Icons CSS Links CSS Lists CSS Tables CSS Display CSS Max-width CSS Position CSS Z-index CSS Overflow CSS Float CSS Inline-block CSS Align CSS Combinators CSS Pseudo-classes CSS Pseudo-elements CSS Opacity CSS Navigation Bar CSS Dropdowns CSS Image Gallery CSS Image Sprites CSS Attr Selectors CSS Forms CSS Counters CSS Website Layout CSS Units CSS Specificity CSS !important CSS Math Functions

CSS Advanced

CSS Rounded Corners CSS Border Images CSS Backgrounds CSS Colors CSS Color Keywords CSS Gradients CSS Shadows CSS Text Effects CSS Web Fonts CSS 2D Transforms CSS 3D Transforms CSS Transitions CSS Animations CSS Tooltips CSS Image Styling CSS Image Centering CSS Image Filters CSS Image Shapes CSS object-fit CSS object-position CSS Masking CSS Buttons CSS Pagination CSS Multiple Columns CSS User Interface CSS Variables CSS @property CSS Box Sizing CSS Media Queries CSS MQ Examples CSS Flexbox

CSS Responsive

RWD Intro RWD Viewport RWD Grid View RWD Media Queries RWD Images RWD Videos RWD Frameworks RWD Templates

CSS Grid

Grid Intro Grid Container Grid Item

CSS SASS

SASS Tutorial

CSS Examples

CSS Templates CSS Examples CSS Editor CSS Snippets CSS Quiz CSS Exercises CSS Website CSS Syllabus CSS Study Plan CSS Interview Prep CSS Bootcamp CSS Certificate

CSS References

CSS Reference CSS Selectors CSS Combinators CSS Pseudo-classes CSS Pseudo-elements CSS At-rules CSS Functions CSS Reference Aural CSS Web Safe Fonts CSS Animatable CSS Units CSS PX-EM Converter CSS Colors CSS Color Values CSS Default Values CSS Browser Support

CSS Image Filter Effects


The CSS filter property is used to add visual effects to elements.



CSS Filters

The CSS filter property is used to add visual effects (like blur and saturation) to elements.

Within the filter property, you can use the following CSS functions:

  • blur()
  • brightness()
  • contrast()
  • drop-shadow()
  • grayscale()
  • hue-rotate()
  • invert()
  • opacity()
  • saturate()
  • sepia()

The CSS blur() Function

The blur() filter function applies a blur effect to an element. A larger value will create more blur.

Example

Apply different blur effects to <img> elements:

#img1 {
  filter: blur(2px);
}

#img2 {
  filter: blur(6px);
}
Try it Yourself »


The CSS brightness() Function

The brightness() filter function adjusts the brightness of an element.

  • Values over 100% will provide brighter results
  • Values under 100% will provide darker results
  • 0% will make the image completely black
  • 100% is default, and represents the original image

Example

Make an image brighter and darker than the original:

#img1 {
  filter: brightness(150%);
}

#img2 {
  filter: brightness(50%);
}
Try it Yourself »

The CSS contrast() Function

The contrast() filter function adjusts the contrast of an element.

  • Values over 100% increases the contrast
  • Values under 100% decreases the contrast
  • 0% will make the image completely gray
  • 100% is default, and represents the original image

Example

Increase and decrease the contrast for an image:

#img1 {
  filter: contrast(150%);
}

#img2 {
  filter: contrast(50%);
}
Try it Yourself »

The CSS drop-shadow() Function

The drop-shadow() filter function applies a drop-shadow effect to an image.

Example

Add different drop-shadow effects to an image:

#img1 {
  filter: drop-shadow(8px 8px 10px gray);
}

#img2 {
  filter: drop-shadow(10px 10px 7px lightblue);
}
Try it Yourself »

The CSS grayscale() Function

The grayscale() filter function converts an image to grayscale.

  • 100% (or 1) will make the image completely grayscale
  • 0% (or 0) will have no effect

Example

Set various grayscale for an image:

#img1 {
  filter: grayscale(1);
}

#img2 {
  filter: grayscale(60%);
}

#img3 {
  filter: grayscale(0.4);
}
Try it Yourself »

The CSS hue-rotate() Function

The hue-rotate() filter function applies a color rotation to an element.

This function applies a hue rotation on the image. The value defines the number of degrees around the color circle the image will be adjusted. A positive hue rotation increases the hue value, while a negative rotation decreases the hue value. 0deg represents the original image.

Example

Set various color rotations for an image:

#img1 {
  filter: hue-rotate(200deg);
}

#img2 {
  filter: hue-rotate(90deg);
}

#img3 {
  filter: hue-rotate(-90deg);
}
Try it Yourself »

The CSS invert() Function

The invert() filter function inverts the color of an image.

  • 100% (or 1) will make the image completely inverted
  • 0% (or 0) will have no effect

Example

Invert the colors of an image:

#img1 {
  filter: invert(0.3);
}

#img2 {
  filter: invert(70%);
}

#img3 {
  filter: invert(100%);
}
Try it Yourself »

The CSS opacity() Function

The opacity() filter function applies an opacity effect to an element.

  • 100% (or 1) will have no effect
  • 50% (or 0.5) will make the element 50% transparent
  • 0% (or 0) will make the element completely transparent

Example

Set various opacity for an image:

#img1 {
  filter: opacity(80%);
}

#img2 {
  filter: opacity(50%);
}

#img3 {
  filter: opacity(0.2);
}
Try it Yourself »

The CSS saturate() Function

The saturate() filter function adjusts the saturation (color intensity) of an element.

  • 0% (or 0) will make the element completely unsaturated
  • 100% (or 1) will have no effect
  • 200% (or 2) will make the element super saturated

Example

Set various saturations for an image:

#img1 {
  filter: saturate(0);
}

#img2 {
  filter: saturate(100%);
}

#img3 {
  filter: saturate(200%);
}
Try it Yourself »

The CSS sepia() Function

The sepia() filter function converts an image to sepia (a warmer, more brown/yellow color).

  • 100% (or 1) will make the image completely sepia
  • 0% (or 0) will have no effect

Example

Set various sepia for an image:

#img1 {
  filter: sepia(1);
}

#img2 {
  filter: sepia(60%);
}

#img3 {
  filter: sepia(0.4);
}
Try it Yourself »


CSS Filter Functions

The following table lists the CSS filter functions:

Function Description
blur() Applies a blur effect to an element
brightness() Adjusts the brightness of an element
contrast() Adjusts the contrast of an element
drop-shadow() Applies a drop-shadow effect to an image
grayscale() Converts an image to grayscale
hue-rotate() Applies a color rotation to an element
invert() Inverts the color of an image
opacity() Applies an opacity effect to an element
saturate() Adjusts the saturation (color intensity) of an element
sepia() Converts an image to sepia

×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2024 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.