can you please let me know how to write single statement to with specific for IE, Mozilla, Chrome.
-
5I got [this](http://stackoverflow.com/questions/4332117/how-to-write-specific-css-for-mozilla-chrome-and-ie?rq=1) from the right hand side column and am sure you would've got that while typing the question... – Mr. Alien Dec 11 '13 at 12:31
-
The better practice is never use single statements for each browser ... maybe the only one are for IE <= 8. – DaniP Dec 11 '13 at 13:20
1 Answers
Whether using this approach to target browsers specifically is a good idea or not is a seperate question in itself. However, assuming you have a legitimate reason to target browsers as you asked, there are couple of ways you can achieve your goal
CSS Browser Specific Selector Hacks
browserhacks.com has an exhaustive list of browser specific selector based hacks that will apply to only specific browsers. Also, as Mr. Alien suggests, this question details browser hacks well too.
CSS Browser Selector JS Library
This library will add classes to the root html
tag that indicate browsers and more other potentially useful info: https://github.com/ridjohansen/css_browser_selector/
Once you've included the library, it . You can use those classes to target specific browsers in css similar to this:
.chrome .some-class { } /* Will only apply in chrome (all versions) */
.ie .some-class { } /* Will only apply in IE (all versions) */
.ie7 .some-class { } /* Will only apply in IE7 */
.opera .some-class { } /* Will only apply in Opera (all versions) */
The library will add a bunch of classes that can be used to target based on browser, browser version, platform, platform version, device, device version etc. Check the documentation in the github link for full details.

- 1
- 1

- 5,456
- 2
- 29
- 40