I have the following HTML code: <tr><th>Header</th><tr> <tr><td>Cell</td></tr> Code (markup): And I'm using CSS3 to select the alternate row headers using the nth-child pseudo-class. However, sometimes my table has the <tr><th> row, and sometimes it doesn't, but I still want to begin the <th><td> with the odd row. My problem is that since it goes: odd, even, odd, even, if the TH is present then the TD will get the even class. In pseudo code I want something like: var beginOn = table.hasChild('th') ? 'even' : 'odd'; Code (markup):
Actually, I've probably answered my own question, so I'll post the solution. Technically speaking you're supposed to have the <thead> and <tbody> nodes designating the header and body of the table, so if you're sticking to the standards, then to achieve the aformentioned, it would simply be a case of: table tbody tr:nth-child(even) Code (markup): Since that would jump straight to the tbody section, leaving the thead section well alone.