CSS

I stumbled upon this article from Michael Barrett http://abouthalf.com/development/poor-mans-nth-child-selector-for-ie-7-a..., explaining how to use adjacent sibling selector to fake nth-child pseudo selectors.

So I wondered if this trick could be used to fake odd / even too.

And the answer is "Yes, kind of". If you need only a limited amount of odd / even children, that will work, but you have to write as many selectors as odd children you have :

table tr {
background: red; // odd
}
table tr:first-child + tr,
table tr:first-child + tr + tr + tr,
table tr:first-child + tr + tr + tr + tr + tr,
table tr:first-child + tr + tr + tr + tr + tr + tr + tr
//...and so on {
background: blue; // even
}

Syndicate content