Descendant selector usage
I have a block of html code that I don't have control over. I do, however, have access to alter the stylesheet. I need to add some style to the first nested table. Here is the html:
<table class="outer">
<tr>
<td>
<table>
.
.
.
</table>
</td>
<td>
.
.
.
</td>
</tr>
</table>
I want to style the firs开发者_开发知识库t nested table. I thought that this would be the correct selector to do so but it doesn't seem to be working:
table.outer tr > td:first-child > table
It seems to want to style all tables and not just those inside the first td.
Instead of assuming your ...
are made of non-table elements as per my comment, I'll assume that they are other table elements.
Here then is a very specific selector you could try (adds more :first-child
pseudo-classes and more >
combinators):
table.outer > tbody > tr:first-child > td:first-child > table:first-child
You should note that this is also the first <tr>
you want to target.
table.outer tr:first-child > td:first-child > table
精彩评论