I want to put padding-right:10px to my style for only IE , but I don't want other browsers to render this padding. Any solution to define padding only for IE, but protected from Firefox, chrome, and others?
+8
A:
Use conditional comments.
Edit: If you really really want to hack the CSS - which you shouldn't - use
* + HTML .myClass {}
Which will target IE7 (I don't know how this works with IE8 in either mode - so please don't do it.)
edeverett
2009-07-30 10:31:47
other way please? I have tried _padding-right:10px but not work. thanks!
Sinal
2009-07-30 10:34:39
conditional comment isn't _property. check the link he gave
streetpc
2009-07-30 10:41:30
There is no other way. The "*+html" hack works for IE7 and IE8 in IE7-mode. What has "_padding-right:10px" to do with his answer?
x3ro
2009-07-30 10:43:30
You should also check http://www.evotech.net/blog/2007/05/ie7-only-css-hacks-examples/
x3ro
2009-07-30 10:45:30
+6
A:
<!--[if IE 6]>
<style type="text/css">
/*For example, this creates special instructions for IE 6*/
.myDiv { padding-right: 10px; }
</style>
<![endif]-->
Make sure to respect the flow of your rules. You'll want this value to override any previous padding-right value, so place this after your other rules. Or you can add !important after the rule, giving you:
<!--[if IE 6]>
<style type="text/css">
.myDiv { padding-right: 10px!important;
</style>
<![endif]-->
Stackoverflow Archive:
- Do you put IE conditionals in the css file or in the html file?
- CONDITION CSS differentiate between IE6 to IE7
- Is there a way to do browser specific conditional CSS inside a *.css file?
- How can I have a CSS style different for IE6?
- css conditional formatting
- IE CSS alignment issues
- Why should I use conditional stylesheets?
Jonathan Sampson
2009-07-30 10:32:00
A:
we use
//padding-right: 10px;
I guess every special character is ignored by every other browser..
Tommy
2009-07-30 11:01:40
A:
At webdevout.net there is a very thorough article examining the pros and cons of CSS hacks.
Wabbitseason
2009-07-30 11:19:08
A:
Read this and check that solves your problem. http://praveenbattula.blogspot.com/2009/05/ie-hacking-apply-styles-only-to-ie.html
Rare Solutions
2010-03-24 18:43:36