Inline CSS IE hack

Is it possible to create, for example, hacking a window model using inline CSS?

For example:

<div id="blah" style="padding: 5px; margin: 5px; width: 30px; /*IE5-6 Equivalent here*/">

Thanks!

+6
css
source share
7 answers

You can also use the hack prefix in the inline styles:

 <div style="*background:red"></div> 

Just make sure you put IE hacks at the end of the style attribute. However, secondly, I express the opinion that, when possible, inline styles should be avoided. Conditional comments and a separate CSS file for Internet Explorer seem to be the best way to solve such problems.

+12
source share

I’ll go outside - delete the class on this element or use the ID that you have and process the style from the outside.

I also agree with the conditional comment answers preceding mine.

That said: as the last absolute, you can use the following style hacks to target <= IE6 and even IE7. The problem arises when / if they fix IE8 to defeat your hack.

 .foo { padding: 5px; ^padding: 4px; /* this targets all IE, including 7. It must go first, or it overrides the following hack */ _padding: 3px; /* this targets >= IE6 */ width: 30px; } 

Good luck.

+10
source share

Without arguments for or against CSS hacks in person, if I needed to do something like this, I would rather use a conditional comment:

 <!--[if lt IE 7]> <style> #blah { padding: 5px; margin: 5px; width: 30px; } </style> <![endif]--> 
+3
source share

The most suitable answer is no . (Edit: to be clear, I mean, don't do this inline, I don't mean, don't use CSS hacks.)

Edit: this does not work, IE ignores the conditional comment. Leaving the answer here so as not to be a bastard.

The next most suitable answer is conditional comments:

 <div id="blah" style="padding: 5px; margin: 5px; width: 30px; <!--[if lte IE 6]> ... <![endif]-->"> 
0
source share

Keep in mind that IE 6 needs to crack the model in quirks mode, but not in standard mode. IE 5 and IE 5.5 require BMH all the time.

So, if you are in standard mode, you need to use something like the original voice-family hack (which targets IE 5.X, not IE 6). If you are in quirks mode, any old IE <= 6 hack will do.

(The content of your question tells me that your page is displayed in quirks mode.)

0
source share

Yes, like all of the above, if you can avoid it, do it! But if you really need to log in, then the parsing filters are probably best of all are certain characters that you can use for properties like underscore fake in ie6

 print("code sample"); style="position:relative;padding:5px; _position:absolute; _padding:10px;" 

ie6 will still get underlined styles, everyone else will just ignore them!

Instead of underlining, the value is also used!

play and see what happens, but again, as above, try to avoid the plague :)

0
source share

The best solution is to work in standard mode and not in Quirks Mode ..., which saves you the need for most of your manual models.

In addition, conditional comments with an IE-specific style sheet are much cleaner and easier to maintain. This method has been good enough for most designers with first-class design over the past few years ... if only something specific about your site that requires everything to be built-in, I suggest taking a step back and looking at the root issues, not on how you can correct these small symptoms as they appear. alt text http://sonicloft.net/im/52

0
source share

All Articles