How to write browser specific css

Usually when it comes to browser specific css we often mean IE specific code. You might be aware of the conditional comments tag you can use to target different versions of Internet Explorer. But 2day i’ll be showing you a much simpler way to tame IE 6 and 7 to your needs . Lets suppose for some reasons you want a div to have a height of 10px in all browsers, but a height of 12px in IE 7 and 15px in IE 6, here is how it can be done without the use of conditional comments:

div {
//for all browsers

//for IE 6,others will ignore this

//for IE 7

isnt it much simpler than writing conditional comments?
The same technique can be applied to other properties as well. You can even use this hack to request your IE 6 users to upgrade to a modern browser,how? Just make a div and write your message in it and set its “display” to “none” while set “_display” to “block”.This will simply tell all browsers not to display the div while IE 6 will. Hope you enjoyed the post.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

2019 All rights reserved | Powered by WordPress
Back to top
Theme by