Smithy
Smithy

Reputation: 405

CSS selector class and element order

In a HTML table with class of 'testtable', is there any difference between selecting a element in that table with the following two css selectors?

.testtable td{}

and

td.testtable{}

Upvotes: 0

Views: 173

Answers (1)

Steve Sanders
Steve Sanders

Reputation: 8651

.testtable td{} selects a td that has a parent with the class testtable, for example:

<table class="testtable">
    <td>I'm selected</td>
</table>

td.testtable{} selects a td that has the class testtable, for example:

<table>
    <td class="testtable">I'm selected</td>
</table>

Upvotes: 4

Related Questions