<div id="myelement">
<table class="myclass">
<tbody>
<tr>
<td>something</td>
<td>
<table>
<tbody>
<tr> hari </tr>
</tbody>
</table>
</td>
</tr>
<tr>
foo
</tr>
</tbody>
</table>
</div>
"//tbody[1]"
I am looking for a CSS expression which should select first tbody
which is a direct child of table
, not the one inside tr
.
If I use the CSS as tbody
, then it would select 2, but I am looking for a way to fix it here. I know table>tbody
will work, I am looking for if any more is there or not. As in my case I can't use table>tbody
.
tbody tr td:first-of-type {
color: red;
}
DEMO
td:first-of-type
will works too.
:nth-of-type(1)
and :first-of-type
are the same. Docs
Try using the immediate child selector >
:
.myclass > tbody
Or if you just want the first one inside that div
, you can do:
#myelement:first-child tbody
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With