Code has been added to clipboard!

The CSS Box-Shadow Property

Reading time 2 min
Published Aug 8, 2017
Updated Oct 2, 2019

What's a CSS box shadow?

Using the box-shadow property, you can add a CSS box shadow effect for a selected element:

Example
div {
    box-shadow: 15px 15px 10px #4286f4;
}

CSS shadow syntax

The syntax for box-shadow is as follows:

box-shadow: h-shadow v-shadow blur spread color;

Example
div {
  box-shadow: 14px 22px 10px red; 
}
Udacity
Pros
  • Simplistic design (no unnecessary information)
  • High-quality courses (even the free ones)
  • Variety of features
Main Features
  • Nanodegree programs
  • Suitable for enterprises
  • Paid certificates of completion
Coursera
Pros
  • Professional service
  • Flexible timetables
  • A variety of features to choose from
Main Features
  • Professional certificates of completion
  • University-level courses
  • Multiple Online degree programs
Datacamp
Pros
  • Great user experience
  • Offers quality content
  • Very transparent with their pricing
Main Features
  • Free certificates of completion
  • Focused on data science skills
  • Flexible learning timetable

Property values

Value Description
none Default No CSS box shadow is displayed.
h‑shadow Required The horizontal offset.
Use a positive value for the right side of the box and a negative value for the left.
v‑shadow Required The vertical offset.
Use a positive value for the area below the box and a negative value for the area over the box.
blur Required The level of blur.
0 represents a sharp CSS box shadow. Higher number means more blur in a bigger area.
spread Optional The size of the CSS box shadow.
Use a positive value for bigger size and a negative value for smaller size.
color Optional The color of the CSS box shadow. Black by default.
Specify a custom one using color names, RGB, RGBA, HEX, HSL or HSLA values.

Tip: you can use the inset keyword to change the outset CSS shadow to an inner shadow.

Browser support

Browser image
Chrome
10+
Browser image
Edge
12+
Browser image
Firefox
4+
Browser image
IE
9+
Browser image
Opera
10.5+
Browser image
Safari
5.1+

Mobile browser support

Browser image
Chrome
18+
Browser image
Firefox
4+
Browser image
Opera
All
Browser image
Safari
5+

Latest Udacity Coupon Found:

Verified STAFF PICK

75% OFF COURSES

Udacity Black Friday Offer

The best time to save on Udacity courses is now - follow this coupon to access a 75% Udacity Black Friday discount & enjoy learning at a very low cost!

Expiration date: 25/01/2021
3176 People Used
Only 97 Left
Rating
5.0