HTML Academy
Color Rotation, hue-rotate
CSS filters5/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
Shadow, drop-shadow
  • Sign up
  • Log in

Loading…
Everything will be ready in few seconds

  • Theory
  • Theory
  • Comments

Blur and Opacity

Not all filters work with color. For example, a blur filter makes a photo look out of focus, whereas an opacity filter can make the subject partially transparent.

The blur filter blurs the subject. Its value is set in pixels of 0px or higher.

.effect {
  filter: blur(5px); /* blur at 5px */
}

The opacity filter does the opposite: it sets the opacity of the subject. It works exactly the same as the opacity property. The valid values range from0 to1 or from 0% to 100%.

.effect {
  filter: opacity(0.5); /* The subject is half opaque. */
  filter: opacity(0%); /* The subject is completely transparent. */
}

There is a distinction between the filter and opacity property that you cannot see. Some browsers use hardware acceleration to render filters, but acceleration is not used for the opacity property. Therefore, if you apply an opacity filter, it can have significantly better performance over a similar property.

Comments

  • index.html
  • style.css
HTML
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Blur and Opacity</title> <link href="course.css" rel="stylesheet"> <link href="style.css" rel="stylesheet"> </head> <body> <div class="image"> <img src="img/spb-3.jpg" alt=""> </div> <div class="compare"> <div class="compare-left blur"> <div class="image"> <img src="img/spb-3.jpg" alt=""> </div> </div> <div class="compare-right opacity"> <div class="image"> <img src="img/spb-3.jpg" alt=""> </div> </div> </div> </body> </html>
CSS
.blur img { } .opacity 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 blur filter with the value 5px to the image in the .blur block,
    2. and apply the opacity filter with the value 0.4 to the image in the .opacity 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.