06. Box Border Effects box-shadow

Just like how we can apply a shadow on text, we can also apply a shadow on a box.

Box Shadow

To add a shadow around a box, we can use the box-shadow property.

There are six values that we must pass it, in order:

Horizontal offset
How far the shadow should be off to the right.
Vertical offset
How far the shadow should below the box edge.
Blur
To blur our shadow, we specify our third value, or the blur-radius.
The higher the value, the more blurry our shadow becomes.
Spread distance
The higher the value, the larger the shadow.
Color
Lastly, we may specify a color, the default being black.
Inner Shadow (optional)
To add an inner shadow, we insert the value "inset".

The following code will produce the Sample Box below:

#box {
  box-shadow: 2px 4px 7px 2px blue;
  margin: 10px;
  padding: 10px;
}
Sample Box

Build modern and responsive webpages

High Performance Web Sites

Build modern and responsive webpages Try Front-end

Want your web site to display more quickly? This book presents 14 specific rules that will cut 25% to 50% off response time when users request a page. Author Steve Souders, in his job as Chief Performance Yahoo!, collected these best practices while optimizing some of the most-visited pages on the Web.

$ Check price
29.9929.99Amazon 4.5 logo(63+ reviews)

More Front-end resources

Aching back from coding all day?

Foam Seat Cushion

Aching back from coding all day? Try Back Problems

This foam seat cushion relieves lowerback pain, numbness and pressure sores by promoting healthy weight distribution, posture and spine alignment. Furthermore, it reduces pressure on the tailbone and hip bones while sitting. Perfect for sitting on the computer desk for long periods of time.

$ Check price
99.9599.95Amazon 4.5 logo(9,445+ reviews)

More Back Problems resources

Ad