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?
Asked
Active
Viewed 5,375 times
4 Answers
8
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
- 8,012
- 33
- 28
-
other way please? I have tried _padding-right:10px but not work. thanks! – Sinal Jul 30 '09 at 10:34
-
conditional comment isn't _property. check the link he gave – instanceof me Jul 30 '09 at 10:41
-
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? – fresskoma Jul 30 '09 at 10:43
-
You should also check http://www.evotech.net/blog/2007/05/ie7-only-css-hacks-examples/ – fresskoma Jul 30 '09 at 10:45
6
<!--[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?
0
we use
//padding-right: 10px;
I guess every special character is ignored by every other browser..

Tommy
- 4,011
- 9
- 37
- 59