Is there a more efficient way to apply a specific background color to multiple columns in a table without using a CSS class for each column?
I have a large table with many rows and columns, and I want to minimize unnecessary code.
Currently, I am utilizing the td:nth-of-type
property like this:
.demo tr.selectedRow td:nth-of-type(9), .demo tr.selectedRow td:nth-of-type(10), .demo tr.selectedRow td:nth-of-type(11), .demo tr.selectedRow td:nth-of-type(12), .demo tr.selectedRow td:nth-of-type(13), .demo tr.selectedRow td:nth-of-type(14), .demo tr.selectedRow td:nth-of-type(15), .demo tr.selectedRow td:nth-of-type(16) { background-color: #fff16b; }
<table border="1" class="demo"> <tr> <td>not selected</td> </tr> <tr class="selectedRow"> <td>not selected</td> <td>not selected</td> <td>not selected</td> <td>not selected</td> <td>not selected</td> <td>not selected</td> <td>not selected</td> <td>not selected</td> <td>selected</td> <td>selected</td> <td>selected</td> <td>selected</td>...
I'm looking for ways to streamline this process even further.
The documentation is not very helpful...