This Website And All Of It's Contents Are Protected By The First Amendment Of The Constitution Of The United States Of America.

To Just Be Able To Do It,
Is To Just Be Able To Do It.

HTML CSS Notes
CSS Box Shadow Views

How box-shadow works.

box-shadow: 10px 10px 10px gray;

Box Shadows can be applied to divs and other html elements that are the same as or similar to divs.

box-shadow: 10px 10px 10px sienna;

Box Shadows can be applied to divs with or without borders. I like borders so the rest of the examples on this page will have borders around it.

box-shadow: 10px 10px;

This is the shortest box-shadow code. It only has two numbers.

The first number is required and it is the h offset (horizontal offset) (left or right).

The second number is required and it is the v offset (vertical offset) (bottom or top).

If no color is specified, the default color of the box-shadow will be the same color as the text color inside of it. If there is no text inside of it the color of the box-shadow will be the same as the default color of text which is black.

box-shadow: -10px -10px;

You can use negative numbers in the box-shadow.

Positive numbers will put the shadow on the right and bottom sides.

Negative numbers will put the shadow on the left and top sides.

box-shadow: 10px 10px 10px;

The third number is the blur radius. It is optional, which means it is not necessary for the code to work, however it is good to have. It can diffuse the shadow making it softer if you don't want a hard shadow.

box-shadow: 10px 10px 10px 10px;

The fourth number is the spread radius. It is also optional. You can use either a positive or negative number. A positive number will spread the shadow radius farther and a negative number will reduce the shadow radius.

box-shadow: 10px 10px 10px -10px;

The spread radius with a negative number.

box-shadow: 10px 10px 10px 10px blue;

In fifth place we have the color option. It would be in third place if you didn't use the blur or spread radius and in fourth place if you only omit the spread radius.

box-shadow: 10px 10px 10px teal;

The color in fourth place without the spread radius.

box-shadow: 10px 10px 10px lightcoral inset;

By default the box-shadow is an outset shadow, which means the shadow is on the outside of the div.

However, if you add the word inset to the code after the color code, providing that you use a color, the shadow will become an inset shadow, which obviously means it will be on the inside of the div.

box-shadow: -10px -10px 10px lightcoral inset;

You can use positive or negative numbers for the h and v offsets.

As you can see in the example above, the inset shadow is opposite of the outset shadow in that the positive numbers will put the inset shadow at the left and top sides of the div and the negative numbers will put the shadow at the right and bottom of the div.

box-shadow: 10px 10px 10px lightseagreen inset, 10px 10px 10px lightseagreen;

You can use multible box shadows on the same div.

The syntax for this is to simply use a comma to seperate each one appropriately. The semicolon always goes at the end in CSS code.

As far as I know you can use as many as you want. I don't know if there is a limit or what it might be if there is one.

box-shadow: 0px 22px 70px 4px rgba(0, 0, 0, 0.56);

You can experiment with all different kinds of code combinations.

Here we have 0 pixels of horizontal offset, 22 pixels of vertical offset, 70 pixels of blur radius, and 4 pixels of spread radius, with the color black using the rgba color code with an alpha channel of zero point 56.

For the color code in CSS you can use one of the 140 color name codes, or you can use the rgb, rgba, hexadecimal, hsl, hsla color codes scale, or maybe something else. I haven't looked it up thoroughly yet, so I don't know if they have added anything to it yet, or if they will.

box-shadow: 0px 0px 0px 3px tomato, 0px 0px 0px 6px orange, 0px 0px 0px 9px gold, 0px 0px 0px 12px mediumaquamarine, 0px 0px 0px 15px blue;

An example of a different box-shadow code combination.

box-shadow: 0px 0px 0px 2px blue inset, 10px -10px 0px -3px white, 10px -10px green, 20px -20px 0px -3px white, 20px -20px gold, 30px -30px 0px -3px white, 30px -30px orange, 40px -40px 0px -3px white, 40px -40px red;

Another example of a different box-shadow code combination.

box-shadow: 4px 4px 2px darkgray inset, -4px -4px 2px darkgray inset, 2px 2px red, -2px -2px red, 4px 4px dodgerblue, -4px -4px dodgerblue, 0px 20px 40px 4px rgba(0, 0, 0, 0.5);

The code for the 3 examples above I found on the internet while I was looking this stuff up. I may have changed them a little bit just to make it easier for me. If you look this stuff up for yourself, you may find lots of other cool codes to use for your box-shadow codes too or you can just create your own.

border: 3px solid black; box-shadow: 5px 5px 10px 5px gray;

Note; this short box-shadow tutorial may not cover all there is to know about box shadows. These are my personal CSS notes that I can refer to when I need to remember how they work. There are a few other minor things that I didn't mention here that are kind of irrelavent to me, because I already know them. However, explaining every little single detail about computer code can get to be a little tedious and boring, so I prefer to just keep it simple, straightforward, and easy to understand.

Copyright © 2022 - 2026 By Frederick Charles Jenkins Morton. All Rights Reserved.