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 element. Its value is set in pixels and must be 0px or higher.

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

The opacity filter sets the opacity of the element. It works exactly the same as the opacity property. The valid values range from 0 to 1 or from 0% to 100%.

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

There can be performance differences between the filter and the opacity property. Both can use hardware acceleration, and their performance depends on the browser and the content being rendered. An opacity filter is not guaranteed to be faster than the opacity 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−2026

    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.