Child Hack

From CSS Discuss

Jump to: navigation, search

This hack is DEPRECATED and should not be used due to the imminent release of IE 7. See the official IE blog for details.

This Css Hack uses a Child Selector to hide rules from Internet Explorer and other less capable Web Browsers . More advanced browsers ( Mo Zilla / Opera Six + / Sa Fari ) read the selector correctly.

No invalid CSS is used, and it is quite simple really.

For the HTML fragment:

<div id="top"> ... </div>


#top { ... } /*will work in pretty much every browser*/


body > #top { ... } /*will only work in the better browsers*/

This can be handy for applying layouts that require Fixed Position , margin:auto or alpha transparent PNGs (or quite a number of other things).

Personal tools