CSS Tricks: Give IE 6 first-child Psuedo Class Suppor

By on

This is an interesting way to add support for the CSS first-child psuedo class in IE 6:

#element {
behavior:expression(this.firstChild.style.padding = "5px");


Of course it has its drawbacks, most notably is its use of Javascript via Microsoft’s proprietary expression property. Nonetheless, if you stick it in your IE hacks CSS file you’ll have what you need.

Check out the DEMO

ed. Fixed quotes in expression and added a demo. Thanks Ben!