CSS Hack: IE(6) Underscore Hack



K_DivBlueGold


Um die Darstellungs-Problematik in verschiedenen Browsern zu umgehen, kommt man ohne Tricks nicht mehr aus! Dabei ist dem Internet Explorer besondere Aufmerksamkeit zu schenken.
- Nun da gibt es genügend Mittel und Wege aber wir befassen uns hier nur mit dem "Unterstrich-Hack" von Petr Pisar.
Er hat unterallem herausgefunden, daß ein Unterstrich (_) vor CSS Befehlen (validiert zwar nicht das CSS) dafür sorgt, daß die Befehle von allen Browsern ignoriert aber von Internet Explorer richtig erkannt und umgesetzt werden.

In Netscape 4.x werden aber damit alle CSS-Befehle im selben Selektor scheitern.
MacIE hat diesen/e fehler/Eigenschaft nicht.


Beispiel:

Kopiere diesen Code in "Über Mich" und schau dir den Unterschied in FF und IE an.

<style>
.MeinTest { color: red; _color: blue; }
</style>
<p class="MeinTest"> Das Ist Ein Unterstrich-Hack Test </p>

- Wir machen uns diese Eigenschaft zunutze und z.B. positionieren einen Banner,
der in Internet Explorer völlig deplatziert dargestellt wird.
Also wird in den code, innerhalb der geschweiften Klammern des Selectors, dementsprechend zusätzliche Angaben extra für IE eingefügt.

To have the same look in different browsers, sometimes it is necessary to use the CSS Hack. Thereby, the special attention is to be given to the Internet Explore.
We concern here only with "underscore hack" from Petr Pisar.
He found out that Internet Explorer ignores an Underscore (_) at the beginning of any CSS property name, interpreting the declaration as if the underscore wasn’t there. Other browsers do not recognise the property and ignore the declaration.

However, in Netscape 4.x it will fail all CSS orders in the same Selektor.
MacIE doesn't have this bug/feature.


Example:

Copy this code in your "About Me" and, look the difference between FF and IE.

<style>
.MyTest { color: red; _color: blue; }
</style>
<p class="MyTest"> This Is An Underscore Hack Test </p>

- The underscore hack can be used for example to position a banner which is completely displaced in Internet Explore.
Accordingly, we insert for IE additional properties in the code within the braces of the same selector.



K_DivBlueGold


The CSS syntax: a selector, a property and a value:
selector {property: value;}
EXAMPLES
Other Browsers Internet Explorer
property: value; _property: value;
background: green; _background: red;
background-attachment: fixed; _overflow: scroll;
position: fixed; _position: absolute;
width: numberpx; _width: numberpx;
height: numberpx; _height: numberpx;
padding: numberpx; _padding: numberpx;
top: -/+numberpx; _top: -/+numberpx;
left: -/+numberpx; _left: -/+numberpx;
margin-top: -/+numberpx; _margin-top: -/+numberpx;
margin-left: -/+numberpx; _margin-left: -/+numberpx;



K_DivBlueGold