views:

34

answers:

1

If I have a table as in this example:

<table class="detailView">
   <tr>
      <td>Value1</td>
      <td>value2</td>
   </tr>
</table>

How do I style the <tr> and <td> elements only if the table is of class="detailView"?

+5  A: 

Use a CSS class selector:

table.detailView tr {
    // your CSS properties
}

table.detailView td {
    // your CSS properties
}

If your table does not have the detailView class no style will be applied.

John Keyes