The Wayback Machine - https://web.archive.org/web/20240118172744/https://www.geeksforgeeks.org/css-drop-shadow-function/
Open In App
Related Articles

CSS drop-shadow() Function

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

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: 

html




<!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>    


Output:

  

Example 2: 

html




<!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>


Output:

  

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

  • Google Chrome 18
  • Edge 12
  • Internet Explorer not supported
  • Firefox 35
  • Safari 6
  • Opera 15

Learn to code easily with our course Coding for Everyone. This course is accessible and designed for everyone, even if you're new to coding. Start today and join millions on a journey to improve your skills!

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Commit to GfG's Three-90 Challenge! Purchase a course, complete 90% in 90 days, and save 90% cost click here to explore.
Last Updated : 07 Jun, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads
Complete Tutorials