tags:

views:

217

answers:

2

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?

+2  A: 

You can use (html 5) elements that some browsers do not support yet. Also you can specify fallback styling.

A lot of browsers create their own CSS rules for things like text-transform. With Modernizr you can write one rule and Modernizr makes it happen for multiple browsers.

I think it's just convenience.

richard
That's a great point - no need to mess with -webkit, -moz and -khtml extensions and have to think about what browsers support which CSS3 features. I don't know why that didn't occur to me.
Don
+6  A: 

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.

Paul Irish
Coming from one of the creators of Modernizr, I'd have to say, yes, that makes it more clear.Excellent example, too. All 3 cases I was concerned about(capable browser, older browser, older browser with JavaScript off) are handled and the site degrades gracefully.
Don