Is there a difference between table.class tr, th and table .class tr, th?

Is there a difference between table.class tr, th and table .class tr, th?

回答1

table .class tr selects this:

<table>
    <tbody class="class">
        <tr></tr>
    </tbody>
</table>

While table.class tr selects this:

<table class="class">
    <tr></tr>
</table>

 

回答2

table.foo selects tables with the class foo.

table .foo selects all elements that have the class foo, and are inside a table.

So your selector before:

table .class tr, th selects all trs that are inside an element which has class class and is inside a table, as well as all ths on the page.

 

posted @ 2022-03-04 15:57  ChuckLu  阅读(30)  评论(0)    收藏  举报