HTML Academy
Brightness and Contrast
CSS filters2/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
Invert and Saturate
  • Sign up
  • Log in

Loading…
Everything will be ready in few seconds

  • Theory
  • Theory
  • Comments

Grayscale and Sepia

The following two filters have their historical origins in photography: photos were originally black and white or brownish sepia.

Colorless and sepia filters can be used to give your photos an “antique” look.

Colorlessness is assigned using grayscale. Valid values range from 0 to 1, and percentages range from0% to 100%. If the value is set to 0 or 0%, the element will be displayed unchanged.

.effect {
  filter: grayscale(1); /* Full color removal */
  filter: grayscale(50%); /* Removal of half of the colors */
}

Sepia is set using sepia. The valid values are the same as for grayscale.

.effect {
  filter: sepia(1); /* Full sepia effect */
  filter: sepia(25%); /* 25% sepia effect */
}

Comments

  • index.html
  • style.css
HTML
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Grayscale and Sepia</title> <link href="course.css" rel="stylesheet"> <link href="style.css" rel="stylesheet"> </head> <body> <div class="image"> <img src="img/spb-4.jpg" alt=""> </div> <div class="compare"> <div class="compare-left grayscale"> <div class="image"> <img src="img/spb-4.jpg" alt=""> </div> </div> <div class="compare-right sepia"> <div class="image"> <img src="img/spb-4.jpg" alt=""> </div> </div> </div> </body> </html>
CSS
.grayscale img { } .sepia 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. Apply the grayscale(1) filter to the image in the .grayscale block,
    2. and apply the sepia(1) filter to the image in the .sepia 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.