wtf

...now browsing by tag

 
 

Sizzle: Inconsistency between nth() and nth-child() CSS selector

Thursday, December 16th, 2010

We’re using the Sizzle JavaScript library to help us select HTML elements in our suite of Selenium tests.  Sizzle provides all of the useful selectors from CSS3, like nth-child(), as well as some others not provided by CSS3, like nth().  Sounds great, right?  Well, yes… but take a look at the W3C recommendation for nth-child() CSS3 pseudo-class:

The index of the first child of an element is 1.

The Sizzle documentation, on the other hand, states:

:eq/:nth: Finds the Nth element on the page (e.g. :eq(5) finds the 6th element on the page).

W. T. F.?