HTML Academy
Blur and Opacity
CSS filters6/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
The Difference Between box-shadow and drop-shadow
  • Sign up
  • Log in

Loading…
Everything will be ready in few seconds

  • Theory
  • Theory
  • Comments

Shadow, drop-shadow

You can add a shadow to an object using the drop-shadow filter. The filter syntax is the same as the one used for the box-shadow property.

.effect {
  /*
    Black shadow offset by 10px horizontally and
    5px vertically, with a blur radius of 3px
  */
  filter: drop-shadow(10px 5px 3px #000000);

  /* Green shadow that is not offset with a 5px blur radius */
  filter: drop-shadow (0px 0px 5px green);
}

Unlike box-shadow, the filter does not support the inset parameter for the inner shadow.

In addition, as of the time of writing of this section, stretch is not supported in the shadow filter (you can find more details about how stretch is used in the box-shadow property in the “Shadow Play” section).

Comments

  • index.html
  • style.css
HTML
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Shadow, drop-shadow</title> <link href="course.css" rel="stylesheet"> <link href="style.css" rel="stylesheet"> </head> <body> <div class="compare"> <div class="compare-left shadow-1"> <div class="image"> <img src="img/spb-3.jpg" alt=""> </div> </div> <div class="compare-right shadow-2"> <div class="image"> <img src="img/spb-6.jpg" alt=""> </div> </div> </div> </body> </html>
CSS
.shadow-1 { } .shadow-2 { }

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. For the .shadow-1 block, apply the drop-shadow filter with a value of 15px 15px 15px black,
    2. and apply the drop-shadow(0px 0px 20px red) value to the .shadow-2 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.