Sebolains
Sebolains

Reputation: 782

CSS2 Selectors not working on IE8

Does anyone know why the following CSS code is not working on IE8, and yet it's working on EVERY OTHER browser?

table.wrap tr:first-child td, table.wrap tr:last-child td { height:20px; }
table.wrap td:first-child, table.wrap td:last-child { width: 20px; }

I understand that IE8 does not support CSS3 features. But I don't think I'm using CSS3 here.

I sincerely appreciate your help.

Thank you so much!

Upvotes: 3

Views: 3733

Answers (3)

Spudley
Spudley

Reputation: 168685

See Quirksmode.org for a full compatibility chart of all CSS features across all the various browsers.

As you'll see from the link above, IE8 does not support the last-child feature.

It does support first-child, but since you've put them together in the same selector, it will throw the whole thing away because it doesn't recognise the last-child part.

Also note note that Quirksmode first-child as being buggy in IE8, so even though it is supported, you may want to be careful about using it.

To solve the problem, you might want to try an IE hack to get it to support extra CSS features.

One that looks quite good is Selectivizr. You might also want to look into Dean Edwards' ie7.js / ie8.js / ie9.js. Both of these aim to patch missing features into older versions of IE. They're not perfect, but they may resolve the problem for you.

Hope that helps.

Upvotes: 5

DanS
DanS

Reputation: 18463

I believe last-child is a part of css3 and not supported by IE8.

Upvotes: 0

Thom Wiggers
Thom Wiggers

Reputation: 7054

IE isn't compatible: http://reference.sitepoint.com/css/pseudoclass-lastchild

Upvotes: 0

Related Questions