Current spec draft at http://www.whatwg.org/specs/web-apps/current-work/multipage/tabular-data.html#dom-tdth-cellindex says: The cellIndex IDL attribute must, if the element has a parent tr element, return the index of the cell's element in the parent element's cells collection. If there is no such parent element, then the attribute must return 0. the <th> elements in this testcase are not inside a <tr>, so we should be returning 0. Looks like this is a recent spec change; DOM level 1 and 2 did not define behavior for cells that are not in a row, so we returned -1 in that case. That said, compat across browsers is poor here: WebKit returns all sorts of different indices, while Opera seems to not implement this property at all. IE9 returns 0 like the current spec draft says, so I'm guessing hixie just went with the IE behavior for simplicity. Ms2ger, do you think it's worth making the case that returning an obviously invalid value when the value is meaningless is better, or should we just switch to 0?
From code inspection, webkit returns the number of previous siblings that are th/td's.
Even if there is no parent table and other nodes in between so that the ths/tds end up in separate tables in the layout?