I'm looking for a CSS selector to target the first <tr>
in a <table>
.
After searching online, I found some selectors like tr:first-child
and
table *:first-child tr:first-child, table tr:first-child
. Unfortunately, these do not work in my specific case...
Here is some sample HTML code that needs to be addressed:
<table>
<thead>
<tr><th>you should select this row</th></tr>
<tr><th>not this one</th></tr>
</thead>
<tbody>
<tr><td>not this one</td></tr>
</tbody>
</table>
<table>
<colgroup>
<col></col>
</colgroup>
<thead>
<tr><th>you should select this row</th></tr>
<tr><th>not this one</th></tr>
</thead>
<tbody>
<tr><td>not this line</td></tr>
</tbody>
</table>
<table>
<colgroup>
<col></col>
</colgroup>
<tbody>
<tr><td>you should choose this row</td></tr>
<tr><th>not this one</th></tr>
</tbody>
</table>
(Looking for a solution without relying on JavaScript)