I have the following HTML:
<tr>
<td class="column-text">column 1</td>
<td class="column-text">column 2</td>
<td class="column-text">column 3</td>
<td class="column-text">column 4</td>
<td>last column has no class</td>
</tr>
Note that the number of cells with class "column-text" is dynamic.
I have the following CSS:
tr td.column-text:last-child {
color: red;
}
Note that this selector seems not working.
What is the right CSS selector for the last <td>
with class "column-text"?
Thanks and regards.
UPDATE 1
Just wanted to share this, which is puzzling to me. The following is working!
tr td.column-text:first-child {
color: red;
}
But as said in the post, I hope to apply styles to the last cell with the given class.
UPDATE 2
Here is what I did to solve this problem after realizing there is no direct CSS solution based on the input from helping folks. When generating the dynamic html, I added a special class to the last <td>
with "column-text" class.
Thanks to all folks who rushed to help!!!