How to Add Shadow to Button in CSS ? Last Updated : 29 Feb, 2024 Comments Improve Suggest changes Like Article Like Report This article will show you how to add shadow to a button using CSS. Button shadow can enhance its visual appeal and make it stand out on your webpage. This article will cover various approaches to adding shadow to a button using CSS. Table of Content Add Shadow on button using box-shadow PropertyAdd Shadow to Button on HoverAdd Shadow to Button using filter Property with drop-shadowAdd Shadow on button using box-shadow PropertyThe box-shadow property is commonly used to add shadow to elements in CSS. It allows you to specify the horizontal and vertical offsets, blur radius, spread radius, and color of the shadow. HTML <!DOCTYPE html> <html> <head> <title>Button Shadow with box-shadow</title> <style> .button { padding: 10px 20px; background-color: #0e4b10; color: white; border: none; cursor: pointer; box-shadow: 5px 5px 7px rgba(0, 0, 0, 0.6); } </style> </head> <body> <button class="button">GeeksforGeeks</button> </body> </html> Output Explanation:The .button class styles the button with padding, background color, text color, and removes the default border.The box-shadow property adds a shadow with 3px horizontal and vertical offsets, a 5px blur radius, and a semi-transparent black color.Add Shadow to Button on HoverYou can also add a shadow effect to a button when it is hovered over, creating an interactive visual effect. HTML <!DOCTYPE html> <html> <head> <title>Button Shadow on Hover</title> <style> .button { padding: 10px 20px; background-color: #0e4b10; color: white; border: none; cursor: pointer; transition: box-shadow 0.3s ease; } .button:hover { box-shadow: 5px 5px 7px rgba(0, 0, 0, 0.6); } </style> </head> <body> <button class="button">GeeksforGeeks</button> </body> </html> Output Explanation:The setup is similar to the first approach, but we add a transition property to the .button class for a smooth shadow effect when hovering.The :hover pseudo-class is used to change the box-shadow property when the mouse pointer is over the button, making the shadow more pronounced.Add Shadow to Button using filter Property with drop-shadowThe filter property with the drop-shadow function can also be used to add a shadow effect. This approach is particularly useful when you want to apply the shadow to transparent images or SVGs. HTML <!DOCTYPE html> <html> <head> <title>Button Shadow with filter</title> <style> .button { padding: 10px 20px; background-color: #0e4b10; color: white; border: none; cursor: pointer; filter: drop-shadow(5px 5px 7px rgba(0, 0, 0, 0.6)); } </style> </head> <body> <button class="button">GeeksforGeeks</button> </body> </html> Output Explanation:The setup is similar to the first approach, but instead of using the box-shadow property, we use the filter property with the drop-shadow function.The parameters for drop-shadow are similar to those for box-shadow, but drop-shadow can apply to the entire element, including transparent areas. Comment More infoAdvertise with us Next Article How to Add Shadow to Button in CSS ? V vkash8574 Follow Improve Article Tags : Web Technologies CSS CSS-Questions Similar Reads How to Add a Shadow to a Button ? Adding a shadow to the button significantly enhances the visual appeal of the elements, improving the overall look and feel of the application. We can add a Shadow to a Button using different approaches including, the box-shadow property, CSS variables, filter property, and pseudo-class. We can use 5 min read How to Add Shadow in CSS? Shadows in CSS can be used to create depth and visual interest by adding the effect that simulates the shadow of an element. It can be applied to both the text and block elements to enhance the design of the web pages. CSS can provide several properties to achieve different shadow effects, including 4 min read How to Add Shadow to Image in CSS ? Adding shadow to an image can enhance its visual appeal and make it stand out on your webpage. In this article, we will explore various approaches to add shadow to an image using CSS. Table of Content Add Shadow on Image using box-shadow PropertyAdd Shadow on Image on HoverAdd Shadow on Image using 2 min read How to Create a Box Shadow in CSS ? A box shadow in CSS is a visual effect that adds a shadow to an HTML element, creating a sense of depth and dimension. It is a styling technique commonly used to enhance the visual appearance of elements on a webpage. Below are the approaches to creating a box shadow in CSS: Table of Content Using b 2 min read How To Add Custom Box Shadow In Tailwind CSS? Tailwind CSS is a utility-focused CSS framework. Offers a wide range of design utilities. It does include predefined shading, however, for unique design needs, you might want a custom box shadow that goes beyond the default. in this article, you will learn how to extend Tailwind's default shadow and 3 min read Like