CSS | drop-shadow() Function

The drop-shadow() function is an inbuilt function which is used to apply a filter to the image to set the shadow of the image. The drop-shadow() function creates a blurred shadow in a given offset and color.

Syntax:

drop-shadow( offset-x offset-y blur-radius spread-radius color )

Parameters: This function accepts five parameters as mentioned above and described below:

  • offset-x: This parameter sets the horizontal offset of an image. The positive value creates the offset to the right side and negative value creates the offset to the left side.
  • offset-y: This parameter sets the vertical offset of an image. The positive value creates the offset to the bottom side and negative value creates the offset to the top side.
  • blur-radius: It sets the value of blur radius. It is an optional parameter.
  • spread-radius: It sets the value of spread radius. It is an optional parameter.
  • color: It sets the color of drop shadow. Its optional parameter.

Below examples illustrate the drop-shadow() function in CSS:

Example 1:



filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html> 
<html
  
<head
    <title>CSS drop-shadow() Function</title
      
    <style>
        h1 {
            color:green;
        }
        body {
            text-align:center;
        }
        .drop_shadow_effect {
            filter: drop-shadow(10px 10px 10px yellow)
        }
    </style>
</head
  
<body
    <h1>GeeksforGeeks</h1
      
    <h2>CSS drop-shadow() function</h2>
      
    <img class="drop_shadow_effect" src
        alt="GeeksforGeeks logo"
</body
  
</html>    

chevron_right


Output:

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html> 
<html
  
<head
    <title>CSS drop-shadow() Function</title
      
    <style>
        h1 {
            color:green;
        }
        body {
            text-align:center;
        }
        .drop_shadow_effect {
            filter: drop-shadow(-10px -10px 20px yellow)
        }
    </style>
</head
  
<body
    <h1>GeeksforGeeks</h1
      
    <h2>CSS drop-shadow() function</h2>
      
    <img class="drop_shadow_effect" src
        alt="GeeksforGeeks logo"
</body
  
</html>

chevron_right


Output:

Supported Browsers: The browsers supported by drop-shadow() function are listed below:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Safari
  • Opera



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.