Used in casting shadows (often called "Drop Shadows", like in Photoshop) from elements. Here is an example with the deepest possible browser support:

.shadow {
  -webkit-box-shadow: 3px 3px 5px 6px #ccc;  /* Safari 3-4, iOS 4.0.2 - 4.2, Android 2.3+ */
  -moz-box-shadow:    3px 3px 5px 6px #ccc;  /* Firefox 3.5 - 3.6 */
  box-shadow:         3px 3px 5px 6px #ccc;  /* Opera 10.5, IE 9, Firefox 4+, Chrome 6+, iOS 5 */


box-shadow: [horizontal offset] [vertical offset] [blur radius] [optional spread radius] [color];
  1. The horizontal offset (required) of the shadow, positive means the shadow will be on the right of the box, a negative offset will put the shadow on the left of the box.
  2. The vertical offset (required) of the shadow, a negative one means the box-shadow will be above the box, a positive one means the shadow will be below the box.
  3. The blur radius (required), if set to 0 the shadow will be sharp, the higher the number, the more blurred it will be, and the further out the shadow will extend. For instance a shadow with 5px of horizontal offset that also has a 5px blur radius will be 10px of total shadow.
  4. The spread radius (optional), positive values increase the size of the shadow, negative values decrease the size. Default is 0 (the shadow is same size as blur).
  5. Color (required) - takes any color value, like hex, named, rgba or hsla. If the color value is omitted, box shadows are drawn in the foreground color (text color). But be aware, older WebKit browsers (pre Chrome 20 and Safari 6) ignore the rule when color is omitted.

Using a semi-transparent color like rgba(0, 0, 0, 0.4) is most common, and a nice effect, as it doesn't completely/opaquely cover what it's over, but allows what's underneath to show through a bit, like a real shadow.


Inner Shadow

.shadow {
   -moz-box-shadow:    inset 0 0 10px #000000;
   -webkit-box-shadow: inset 0 0 10px #000000;
   box-shadow:         inset 0 0 10px #000000;


Internet Explorer (8 and down) Box Shadow

You need an extra element, but it's do-able with filter.

<div class="shadow1">
  <div class="content">
    Box-shadowed element
.shadow1 {
  margin: 40px;
  background-color: rgb(68,68,68); /* Needed for IEs */

  -moz-box-shadow: 5px 5px 5px rgba(68, 68, 68, 0.6);
  -webkit-box-shadow: 5px 5px 5px rgba(68, 68, 68, 0.6);
  box-shadow: 5px 5px 5px rgba(68, 68, 68, 0.6);

  filter: progid:DXImageTransform.Microsoft.Blur(PixelRadius=3,MakeShadow=true,ShadowOpacity=0.30);
  -ms-filter: "progid:DXImageTransform.Microsoft.Blur(PixelRadius=3,MakeShadow=true,ShadowOpacity=0.30)";
  zoom: 1;
.shadow1 .content {
  position: relative; /* This protects the inner element from being blurred */
  padding: 100px;
  background-color: #DDD;

One-Side Only

Using a negative spread radius, you can get squeeze in a box shadow and only push it off one edge of a box.

.one-edge-shadow {
  box-shadow: 0 8px 6px -6px black;

Multiple Borders & More

You can comma separate box-shadow any many times as you like. For instance, this shows two shadows with different positions and different colors on the same element:

  inset 5px 5px 10px #000000, 
  inset -5px -5px 10px blue;

The example shows how you can use that to create multiple borders:

See the Pen Multiple box-shadow coolness! by Chris Coyier (@chriscoyier) on CodePen.

By applying the shadows to pseudo elements which you then manipulate, you can get some pretty fancy 3D looking box shadows:

See the Pen CSS3 Box Shadows Effects by Halil İbrahim Nuroğlu (@haibnu) on CodePen.

Relevant Links

Browser Support

See snippet at top of page for specifics on vendor prefix coverage. This is one of those properties where dropping the prefixes is pretty reasonable at this point.


  1. User Avatar
    Permalink to comment#

    Good to see this, But this is very basic.
    I was looking for something advanced.

    Anyways thanks for this!

  2. User Avatar
    Druid of Lûhn

    Is there anything like outset, to counteract inset value (using LESS mixin and need to fill the variable set for inset).

  3. User Avatar

    Hi, first i must say i love you site and it has helped me many times.
    one thing about box shadow i am see is that there is a difference between FF and chrome in terms of the distance.
    what i mean is, when useing this code

       box-shadow: 0 4px 10px -10px; 

    in FF it shows a nice shadow on the bottom of the box, but in chrome it is not showing. in order to show i need to change it to this:

       box-shadow: 0 7px 10px -10px; 

    would love to hear what you say about this.

  4. User Avatar
    endüstriyel temizlik ürünleri
    Permalink to comment#

    i like css3 and your site :) but i hate INTERNET EXPLORER :@

  5. User Avatar
    Permalink to comment#

    Here is a test page for comparison. View this page in Chrome, IE, then FireFox (current versions).

    Notice that Chrome and IE (wow!) display it correctly, while FireFox does not render the same way.

    Here is the css:

    td.greybutton {

    background: #696059;

    border-color: #660707 #660707 #5e0f0d;  
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15), inset 1px 0 0 rgba(255, 255, 255, 0.15);
    -moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15), inset 1px 0 0 rgba(255, 255, 255, 0.15);
    border-collapse: separate;
    text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.3);
    padding: 10px 15px 10px 15px;
    color: #F5F5F5;


    td.greybutton:hover {
    background: #944F1B;

    color: #F5F5F5;


    .unselected {

    Here is the markup:

    Menu Item 1

    Menu Item 2

    Menu Item 3

    Any ideas on how to get FireFox to play nice?

    BTW – Safari seems fine too, but Opera renders similarly to FireFox.

  6. User Avatar
    Permalink to comment#

    could you post the code to make Effect 2, I cant figure it out nor understand what you meant by pseudo elements?

    • User Avatar
      Permalink to comment#

      Ok, so I feel like a dufus lol. found where the html and css was lol. But I tried it and it doesnt do anything? I will play with it for a while maybe I am doing something wrong

  7. User Avatar

    Thank you very much for sharing, the effects are very cool.

    In the rule for Effect 7 I don’t really understand how the code works:

    .effect7::after {
        right:10px; /* why reset it if right: 10px was already set above? */
        left:auto; /* why is this necessary, what does it change? */
        transform:skew(8deg) rotate(3deg); /* I'm a bit lost here */

    Why does the subsequent skew and rotate change the shadow the way it does?

  8. User Avatar
    Permalink to comment#

    @Chris Coyier
    Would you mind leaving a suggestion/compliment on my website Yes,I have used the Sitebuilder,but I have a pretty well knowledge of HTML5 & CSS3 as can be demonstrated here:
    How to:Just click on the green lightbulb on the bottom left corner.Thanks!

  9. User Avatar
    Mark Stewart
    Permalink to comment#

    This page is way over the edge. See above, under “The example shows how you can use that to create multiple borders”… What an incredible HTML/CSS/PRIVIEW app. Granted, div id=”init-data” is a hairy translation of the browser surface. But this is the first I’ve seen of this kind of thing. This is the stuff browser programmers look at in wonder (and pride). 10 years maybe and this inspiration surfaces in a literal DOM. So we can write this kind of content in plain English. Another good one, people! This post box has Write and Preview tabs that are also working faultlessly. We’ve all seen this site struggle. Today, you all shine. CSS-Tricks, amazing!

  10. User Avatar
    Permalink to comment#

    I’m trying to apply effect3 on my own div, but it doesn’t work,
    PS : when i put my div outside of all the containers the effect works
    Can you help me please!

  11. User Avatar
    Permalink to comment#

    The PlaceKitten image in your multiple borders example isn’t showing in my browsers (tested in Chrome and FF so far). However, after researching PlaceKitten, I discovered that adding a “g modifier” would display the greyscale version, and sure enough, when I inspected the image in Chrome and changed its source from to, it showed up just fine. So, I presume there’s no color version of that image available.

    Anyway, the article is quite useful and worthy of bookmarking.


  12. User Avatar
    Herman Nz
    Permalink to comment#

    When combined with bootstrap, bootstrap breaks the shadow, how could it be?

  13. User Avatar
    Felix Rizo-Patron
    Permalink to comment#

    Hi there! Cool snippets on your site, thank you very much!

    I have an issue with the shadow. As I put this values the page loads very slow and gets stuck on chrome. Are the values to high?

    -moz-box-shadow: inset 0 200px 430px #000000;
    -webkit-box-shadow: inset 0 200px 430px #000000;
    box-shadow: inset 0 200px 430px #000000;

    Regards, Felix

    • User Avatar
      Permalink to comment#

      Hi Felix,

      Testing your rule locally in Chrome 40.0.2214.91 m on my Windows XP Professional desktop didn’t cause any issues. Could you provide a link to the problem page? There may be a conflict of some sort with other code there because the page in which I tested it had just the HTML5 boilerplate code found at


    • User Avatar
      Felix Rizo-Patron
      Permalink to comment#

      Hi Wayne thank you very much for the testing and the replying. At the end I just took the shadows away. I am also happy that way; no need to look further. Here is the page:
      yes, cheers for you to!

  14. User Avatar
    Johnna Roberts

    I am using shadow effect 5 and I really like all the different shadow effects. But I cannot figure out to make my web page body a different color and keep the white color in my wrapper. When I try to do this I lose the shadow completely. I have tried adding a z-index to my wrapper but that did not change anything. Any ideas or suggestions on how to do this would be greatly appreciated.

    Here is my wrapper code for the wrapper…

    .wrapper {
    background-color: #ffffff;
    color: #000000;
    margin: 0 auto;
    padding: 0;
    text-align: left;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.4);


    • User Avatar
      Emunot Daniel
      Permalink to comment#

      I had the same issue, here’s what I did:

      Get the parent container with bg color.
      Give it “position: relative” and “z-index: -1”

      That worked for me.

  15. User Avatar
    Permalink to comment#

    its good

  16. User Avatar
    Permalink to comment#

    Multiple borders .. I really like that one

  17. User Avatar
    Permalink to comment#

    Very good, thank you

  18. User Avatar
    Permalink to comment#

    Hello people from earth, I am from another world. but I want to learn html an css =P
    my question is about the effect 2, Is it possible to do that with a youtube videoplayer, Thanks in advances! xD

  19. User Avatar
    Permalink to comment#

    hi I’m using this code on my site to highlight images on hover, but some of the boxes are not showing correctly. Maybe because they are different sizes??

    here’s the code I’m using,

    .border img {
      width: 300px;
    -webkit-transition: all 1s ease;
         -moz-transition: all 1s ease;
           -o-transition: all 1s ease;
          -ms-transition: all 1s ease;
              transition: all 1s ease;
    .border img:hover {
      width: 400px;  

    and here’s the rest of the code… its doing exactly what i want when its a square box. If can get it to work on anysize box, that would be great

    .border:hover {
            box-shadow: inset 0 0 0 25px #fcdfff;

    Is there an easy way to make the shadow conform to the size of the box… this is probably happening because if have a hard coded with, and when the box is a different size maybe the shadow isnt working… please hover on where you can see the affect when you hover on the images in the grid (hover images below the slideshow and below the categories)

  20. User Avatar
    Permalink to comment#

    how to get the 4th effect on top fixed navbar ?

    • User Avatar
      Permalink to comment#

      this is what happens is you change position from relative to fixed:

Leave a Comment

Posting Code!

You may write comments in Markdown. This makes code easy to post, as you can write inline code like `<div>this</div>` or multiline blocks of code in triple backtick fences (```) with double new lines before and after.

Code of Conduct

Absolutely anyone is welcome to submit a comment here. But not all comments will be posted. Think of it like writing a letter to the editor. All submitted comments will be read, but not all published. Published comments will be on-topic, helpful, and further the discussion or debate.

Want to tell us something privately?

Feel free to use our contact form. That's a great place to let us know about typos or anything off-topic.