jeudi 2 février 2017

CSS - universal selector instead of coma separated elements

I want to style both th and td elements in such table:

<table>
  <tr>
    <th>Abc</th>
    <td>Cde</td>
  </tr>
  <tr>
    <th>Abc</th>
    <td>Cde</td>
  </tr>
</table>

I don't want to add class to it, so I need to do it like that:

tr td, tr th{background:#dddddd;}
tr:nth-child(even) td, tr:nth-child(even) th{background:#ffffff;}

But... are there any disadvantages to doing it that like below?

tr > *{background:#dddddd;}
tr:nth-child(even) > *{background:#ffffff;}




Aucun commentaire:

Enregistrer un commentaire