HTML Academy
Grayscale and Sepia
CSS filters3/14
Back to the list of tasks
  • 1. Brightness and Contrast
  • 2. Grayscale and Sepia
  • 3. Invert and Saturate
  • 4. Color Rotation, hue-rotate
  • 5. Blur and Opacity
  • 6. Shadow, drop-shadow
  • 7. The Difference Between box-shadow and drop-shadow
  • 8. Applying CSS Filters to Text
  • 9. Challenge: Using Various Filters
  • 10. Combination of Filters
  • 11. Combining the drop-shadow Filters
  • 12. Animating CSS Filters
  • 13. Smooth Transitions and CSS Filters
  • 14. Challenge: Filter Combinations
Color Rotation, hue-rotate
  • Sign up
  • Log in

Loading…
Everything will be ready in few seconds

  • Theory
  • Theory
  • Comments

Invert and Saturate

Two more filters that can be used to create color effects are color inversion and color saturation. As the name implies, inverting the colors reverses them, thereby producing a “negative” image, whereas color saturation makes the colors brighter and higher contrast in a way similar to the color removal filter.

Color inversion is achieved using invert. Valid values range from 0 to 1, and percentages range from0% to 100%.

.effect {
  filter: invert(1); /* Full color inversion */
  filter: invert(50%); /* Half color inversion, all colors are grayscale */
}

Color saturation is achieved using saturate. Valid values range from 0 or more, and percentages range from 0% or more. When the filter is set to a value of 1 or 100%, the element will be displayed unchanged. If it is set to zero, the image will become colorless in the same way as if you had used the grayscale filter.

.effect {
  filter: saturate(2); /* Colors that are twice as bright */
  filter: saturate(50%); /* Colors that are twice as saturated */
  filter: saturate(0); /* Total removal of colors from the image */
}

Comments

  • index.html
  • style.css
HTML
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Invert and Saturate</title> <link href="course.css" rel="stylesheet"> <link href="style.css" rel="stylesheet"> </head> <body> <div class="image"> <img src="img/spb-2.jpg" alt=""> </div> <div class="compare"> <div class="compare-left invert"> <div class="image"> <img src="img/spb-2.jpg" alt=""> </div> </div> <div class="compare-right saturate"> <div class="image"> <img src="img/spb-2.jpg" alt=""> </div> </div> </div> </body> </html>
CSS
.invert img { } .saturate img { }

What didn’t you like in this task?

Thanks! We’ll fix everything at once!

The code has changed, click “Refresh” or turn autorun on.

You’ve gone to a different page

Click inside the mini-browser to shift the focus onto this window.

100%
Goalscompleted
0
    1. Assign the invert filter with the value 0.3 to the image in the .invert block,
    2. then change the inversion value to1,
    3. and apply the saturate filter with the value 5 to the image in the .saturate block.

    Cookies ∙ Privacy ∙ License Agreement ∙ About ∙ Contacts ∙ © HTML Academy OÜ, 2019−2025

    VISAMastercard

    Log in

    or

    Forgot your password?

    Sign up

    Sign up

    or
    Log in

    Restore access

    Have you forgotten your password or lost access to your profile? Enter your email connected to your profile and we will send you a link to restore access.

    Forgot to connect your email to the profile? Email us and we’ll help.