Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why use Modernizr if browsers ignore CSS they don't understand?

I've been working with Modernizr and it is a wonderful resource, just a great project. However, the way I've been using it is:

  • Design with baseline (IE) CSS
  • Enhance with CSS3 effects for advanced browsers

Unless I was going to completely replace the styles based on behavior, why shouldn't I just add styles such as box shadows, gradients and border radii to the stylesheet? If the browser doesn't understand a rule, it will just ignore it, correct? And if JavaScript is off, I can't use it anyway.

Should I be using the above method in the typical case, and Modernizr for advanced cases? Or is there something wrong with relying on browsers to ignore what they don't understand?

like image 896
Don Avatar asked Nov 17 '09 16:11

Don


1 Answers

You're totally right that older browsers completely disregard much of what's in CSS3.

Because of that, I do my css3 in my basic selectors.. but often make use of the modernizr's no-feature classes to handle the older browser case:

div.box { 
         height:50px; 
         -moz-box-shadow: 3px 3px 5px #555; 
         -webkit-box-shadow: 3px 3px 5px #555; }

div.box span.fakeshadow { 
         display:none; 
}

.no-boxshadow div.box span.fakeshadow { 
         display:block; background: url('fakeshadowbg.png'); 
}

I hope that makes it more clear.

like image 63
Paul Irish Avatar answered Sep 19 '22 01:09

Paul Irish