2

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?

Sinal
  • 1,155
  • 5
  • 17
  • 35

4 Answers4

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
6

Conditional IE Rules.

<!--[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:

Community
  • 1
  • 1
Sampson
  • 265,109
  • 74
  • 539
  • 565
0

we use

//padding-right: 10px;

I guess every special character is ignored by every other browser..

Tommy
  • 4,011
  • 9
  • 37
  • 59
0

I am using *padding:xx; Solved my problem.

Bunheng
  • 1
  • 2