Styling the last td in a table with css

vchoke picture vchoke · Dec 11, 2008 · Viewed 159.4k times · Source

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.

Answer

yoavf picture yoavf · Dec 11, 2008

The :last-child selector should do it, but it's not supported in any version of IE.

I'm afraid you have no choice but to use a class.