I’m trying to find a tried and tested script that sniffs the browser version and adds a suitably named class to the <html> or the <body> tags… like <html class="ie7"> or <html class="ff4"> or <html class="safari4">.
I don’t mind if it’s “firefox4” or “ff4” or “firefox_4″… just as long as I can use the class to scope my css.
I could write a script to do this myself but I was wondering if there was a widely used one out there…
Thanks.
For IE, you can use conditional comments like how HTML5 Boilerplate does it. For the others, there are some deprecated methods in jQuery that you can exploit to determine what browser and browser version they’re using, namely jQuery.browser.
And of course, as others are mentioning, you can use Modernizr, although I don’t think it does sniffing of browser type and version exactly how you want. I’m pretty sure it just does feature detection.