Showing posts from December 16, 2010

How to serve different stylesheets only to Safari and Chrome

Well, as you already know that to support Internet Explorer we often serve different CSS files using IE’s special conditional-comment syntax, which is great in terms of having clean and maintainable stylesheets throughout your application, it also mitigates the need of writing CSS hacks which often makes the stylesheets messy and becomes a maintenance nightmare later. You may argue that serving different CSS files only to IE is certainly not an elegant solution and of course it is not, it still requires that extra effort and extra bandwidth for users of Internet Explorer, but it’s somewhat the most practical or possibly the cleanest solution that you can have. As there’s no way to target other browsers using conditional-comment like thing then how would you do it if you ever(though unlikely) have a need to serve different CSS files to some of the modern browsers? Well, seems like I have a solution for you. Recently, I stumbled upon a code while doing “view source” (I do it a