How to Create a Gradient Shadow using CSS ? Last Updated : 16 Oct, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report A gradient shadow in CSS refers to creating a shadow effect that transitions smoothly from one color to another, using gradients. While the box-shadow property doesn't support gradients directly, you can simulate this effect by layering a semi-transparent gradient as the background or using pseudo-elements.Create a Gradient Shadow in CSSHere are the steps required to get the desired linear-gradient shadow:Create an HTML element (button, card, etc.) for the shadow effect.Use a pseudo-class ::before or ::after in CSS with absolute positioning relative to the parent element.Apply small insets (top, right, bottom, left) to adjust the shadow's position.Set a linear-gradient as the background for the pseudo-class, specifying the colors and direction.Use the filter: blur() property to soften the shadow, simulating a realistic effect.Add a z-index to ensure the shadow appears beneath the parent element.Example 1: Linear-gradient Shadow on a RectangleHere we creates a rectangular element with a linear-gradient shadow effect using a pseudo-element. HTML <!DOCTYPE html> <html> <head> <title>Linear-gradient Shadow on a Rectangle</title> <style> * { margin: auto; } .lgShadow { background: rgb(74, 201, 0); padding: 1rem; top: 100px; position: relative; height: 100px; width: 200px; } /* pseudo-class for making gradient shadow. */ .lgShadow::after { content: ""; position: absolute; inset: -.625em; background: linear-gradient(to bottom right, rgb(0, 255, 81), rgb(255, 213, 0)); filter: blur(2.5em); z-index: -1; } </style> </head> <body> <p class="lgShadow"> GeeksforGeeks is a portal for Geeks. </p> </body> </html> Output: Linear-gradient Shadow on a RectangleExample 2: Circular Gradient Shadow Here we displays a circular element with a gradient shadow effect, enhancing the appearance of the text "GeeksforGeeks" while maintaining a visually appealing design. HTML <!DOCTYPE html> <html> <head> <title>Circular Gradient Shadow</title> <style> * { margin: auto; } .lgShadow { background: rgb(201, 77, 0); padding: 3rem; top: 100px; position: relative; height: 100px; width: 200px; border-radius: 50%; } /* pseudo-class for making gradient shadow. */ .lgShadow::after { content: ""; position: absolute; inset: -.625em; background: linear-gradient(to bottom right, rgb(255, 0, 0), rgb(255, 213, 0)); filter: blur(2.5em); border-radius: 50%; z-index: -1; } </style> </head> <body> <p class="lgShadow"> GeeksforGeeks is a portal for Geeks. </p> </body> </html> Output:Circular Gradient Shadow Comment More infoAdvertise with us Next Article How to Create a Gradient Shadow using CSS ? S satyamm09 Follow Improve Article Tags : Web Technologies CSS CSS-Properties CSS-Questions Similar Reads How to create a drop shadow effect using CSS ? In this article, we are going to learn how to create a drop shadow effect using CSS. drop-shadow() is an inbuilt function used to create a blurred shadow in a given offset and color. A drop shadow effect adds depth and visual interest to elements on a web page by creating a shadow behind them. This 3 min read How to create linear gradient background using CSS ? In CSS, we can use the background-color property to set the background color of an element to a specific color. Sometimes we want to add more styling to the element when setting the background color by using the linear-gradient property. CSS linear-gradient property lets you display smooth transitio 4 min read How to create linear gradient text using HTML and CSS ? The linear-gradient is used to create eye-catching text effects, particularly suitable for dark-themed websites or applications. This method involves filling text with linear-gradient color codes, making it look attractive and bold. Linear-gradient text effects are ideal for dark themes and provide 2 min read How to create gradient search button using HTML and CSS ? In this article, we will see how to create a gradient search button using HTML & CSS, along with knowing its basic implementation through the examples. The creation of a gradient search button involves the CSS linear-gradient() function, which sets the background color of the button. Here, we ha 4 min read How to apply gradient as the mask using CSS ? In this article, we will learn how to include the gradient as the mask layer in CSS, along with understanding their basic implementation with the help of suitable examples. The Mask Property with a Gradient is used to create a mask layer, that can be utilized for rendering or hiding the area of the 3 min read Like