How to make a shadow in html

Learn how to create a shadow in HTML with this simple step-by-step tutorial and example code.

To create a shadow effect in HTML, you can use the CSS box-shadow property. This property allows you to add a shadow to an element's frame.

Here's an example of how to use the box-shadow property to add a shadow to a div element:

        
            .shadow {
                width: 200px;
                height: 200px;
                background-color: #f2f2f2;
                box-shadow: 5px 5px 5px #888888;
            }
        
    

In this example, we have created a div element with the class "shadow". We set the width, height, and background color of the element, and then use the box-shadow property to add a shadow. The values for the box-shadow property are horizontal offset, vertical offset, blur radius, and color. In this case, the shadow will be 5 pixels to the right, 5 pixels down, with a blur radius of 5 pixels, and the color of the shadow is #888888.

You can also use the box-shadow property to create different types of shadows, such as inset shadows and multiple shadows. Here's an example of how to create an inset shadow:

        
            .inset-shadow {
                width: 200px;
                height: 200px;
                background-color: #f2f2f2;
                box-shadow: inset 5px 5px 5px #888888;
            }
        
    

In this example, we have added the keyword "inset" before the values for the box-shadow property to create an inset shadow effect.

I hope this helps you to add shadows to your HTML elements using CSS!

h

Answers (0)