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

January 8, 2008 – 11:30 am

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!

Post a Comment

Comments will be sent to the moderation queue.