user3215821
user3215821

Reputation: 263

How to hack css Inline style only on IE?

How to hack css Inline style only on IE ?

to hack css Inline style only on IE in all version, How can i do ?

Like that

<div style = "
               color: #eee;
               border: 1px solid #000;
for ie only // line-height : 32px;     
             "/>

Upvotes: 3

Views: 16906

Answers (3)

dxpkumar
dxpkumar

Reputation: 371

@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
   #myElement {
        /* Enter your style code */
   }
}

Upvotes: 0

Mr. Alien
Mr. Alien

Reputation: 157324

You need to add * before the property name, and that will target only IE7, so you need to write this line-height : 32px; as *line-height : 32px;

As I realized you wanted hacks for each IE, so here you go

  • For IE6 - _
  • For IE7 - *
  • For IE8 - \0
  • For IE9 - \9

Declare styles for IE10 specifically using CSS Only

@media all and (-ms-high-contrast: none) { 
   /* This won't go inline but can be used at document level*/
   /* Declaration Blocks Goes Here*/
}

You can read here for more information on how to declare IE only styles using @media queries


Still I would suggest you to use conditional comments which will make your life much easier instead of declaring inline styles.

Upvotes: 5

JochemQuery
JochemQuery

Reputation: 1547

<!--[if IE]>
    div.classname{
        line-height: 32px; //ie only 
    }
<![endif]-->

Source: http://css-tricks.com/how-to-create-an-ie-only-stylesheet/

Edit:

  • Give that div a class
  • Give that class a specific ie style.

Upvotes: 0

Related Questions