How to make Internet Explorer 8 to support nth child() CSS element?

surajR picture surajR · May 14, 2012 · Viewed 69.2k times · Source

I want to give a zebra stripe effect to my table rows. In all other browsers it can be done using CSS nth child element. But i want to do it IE 8 also. SO how can i do it?

Answer

Samar Panda picture Samar Panda · May 4, 2013

With polyfill : Selectivizr is good enough.

Without polyfill: As IE8 supports first-child you can trick this to support nth-child in iE8 i.e

/*li:nth-child(2)*/
li:first-child + li {}/*Works for IE8*/

Although we cannot emulate complex selectors i.e nth-child(2n+1) or nth-child(odd) for IE8.