What are we facing?
There are not a universal implementation of all CSS selectors across all browsers. This page from Centricle shows a neat matrix of OS/browsers against supported selectors. Particularly, I would like to treat the differences between Internet Explorer browsers. Is there a way to deal the style of my site in different ways across different versions of IE?
The Solution
There at least two solutions, but take them cautiously.
First solution: browser detection via JavaScript by querying three properties of the “BrowserDetect” object. You can detect which browser is visiting your page, not just between versions of IE. This solution is highly controversial as you can’t entirely trust the “BrowserDetect” object and may be not implemented at all.
Second solution: the Internet Explorer conditional comments are a way to deal with it. It is specific for IE browsers. The good thing is that it doesn’t break the rendering of other browsers as they are just comments.
So for example:
<!-- [if gte IE 6]
<style type="text/css">
@import ("ie6up.css");
</style>
-->
It will load the file “ie6up.css” if the IE browser is version is 6 or greater. Any other browser will ignore it as a comment. The caveat is that such style manipulation should be at CSS file level, not in the HTML file. That puts a maintainability cost on it. Again, take it cautiously.
Some external references
[advertisement] Try
Aggiorno for free, the assistant tool for web development you always wanted.