Styling the last td in a table with css

css, html, html-table

Solution

You can use relative rules:

table td + td + td + td + td {
  border: none;
}

This only works if the number of columns isn't determined at runtime.

Problem

I want to style the last TD in a table without using a CSS class on the particular TD. ``` <table> <tbody> <tr> <td>One</td> <td>Two</td> <td>Three</td> <td>Four</td> <td>Five</td> </tr> </tbody> </table> table td { border: 1px solid black; } ``` I want the TD containing the text "Five" to not have a border but again, I do not want to use a class.

Original source