Search code examples
cssvendor-prefix

Are vendor prefixes required for "none"?


Just a quick question about vendor prefixes that I've been wondering about but couldn't find the answer to - are they required when turning off/resetting the style with "none", "initial", "0", etc? For example, if I set a box shadow like this:

   -webkit-box-shadow: -4px 0 10px 2px rgba(0, 0, 0, .1);
   -moz-box-shadow: -4px 0 10px 2px rgba(0, 0, 0, .1);
   box-shadow: -4px 0 10px 2px rgba(0, 0, 0, .1);

If I didn't want the box shadow at a smaller screen size, in the media query would I do simply do "box-shadow: none;" or do I need to do:

  -webkit-box-shadow: none;
  -moz-box-shadow: none;
  box-shadow: none;

Solution

  • If you set your box-shadow like this...

    -webkit-box-shadow: -4px 0 10px 2px rgba(0, 0, 0, .1);
    -moz-box-shadow: -4px 0 10px 2px rgba(0, 0, 0, .1);
    box-shadow: -4px 0 10px 2px rgba(0, 0, 0, .1);
    

    ... you'll need to unset it like this :

    -webkit-box-shadow: none;
    -moz-box-shadow: none;
    box-shadow: none;
    

    Otherwise, browsers that don't support the non-prefixed version of box-shadow won't know that you're setting your box-shadow to none, just like they won't know that you're setting your box-shadow to -4px 0 10px 2px rgba(0, 0, 0, .1) if you only use the non-prefixed version.