Examples of Hacks described in IE7 only CSS Hacks: Explained
This blog entry is the companion page to IE7 only CSS Hacks: Explained which elaborates on how and why these hacks work. Feel free to open this page up in IE7, IE6, Opera and Firefox on the PC, and Safari and Opera on the Mac.
The Star(*) hack
body>div .myClass { *color: #CC33CC; }
The conditional comment
<!–[if IE 7]>
<style type="text/css">
p.conditional {color: #CC33CC;}
</style>
<![endif]–>
The LANG filter
.item {color: #000000;}
html>div .item {color: #CC33CC;}
*:lang(en) .item{color: #666666;}
.item:empty {color: #666666 !important}
<div lang="en">
<p class="item">
This will purple in IE7, grey in Firefox and black in IE6
Triple X Hack
.testx { color: #000000; }
p[id$="testy"] { color:#cc33cc; }
p[id$="testy"]:not([class="xxx"]) { color:#666666; }
@media all and (min-width:0px) { p[id$="testy"] { color:#aaaaaa; } }
This will purple in IE7, grey in Firefox and black in IE6
The Case Sensitive Attribute Hack
p.casesensitive {color: #000000;}
div[align~=left] p.casesensitive {color: #cc33cc;}
div[align~=LEFT] p.casesensitive {color: #666666;}
<div align="left"> <p class="casesensitive">
This will purple in IE7, grey in Firefox and black in IE6</p>
Aimsterloo Hack
a.k.a.
First Child Comment Hack
p.fchild {color: #000000;}
html>div p.fchild {color: #cc33cc;}
div :first-child p.fchild {color: #666666;}
<div><!– useless comment –><div><p class="fchild">
The div should be the first child of the div, but in IE it isn’t…
The above content is in an iFrame due to need to control the body attributes. So, if you want to see the code, right click in the middle of the content and select view from source. You can also view just the guts at http://www.evotech.net/articles/IE7hacksamples.html
There’s also *+html {} which works exactly equivalent to IE6’s * html {}. (That is, no decent browser will ever match it, as it simply can’t match anything in the DOM tree of any actual HTML document.)
Some people use *html.classSelector {}
please explain what is use of it
*:first-child+html .myclasSelector{} Valid css hacks only For IE7
* html .myclasSelector{ } Valid css hacks only For IE6 nad below
Thanks for the expert recommendations! The ie7 hack is working and resolved, FINALLY.