CSS/Selectors/pseudo-classes/:last-of-type

From Web Education Community Group
< CSS‎ | Selectors
Revision as of 19:00, 21 November 2011 by Rworth (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Pseudo-class :last-of-type

The :last-of-type pseudo-class represents an element that is the last sibling of its type in the list of children of its parent element. Same as :nth-last-of-type(1).

Syntax

selector:last-of-type{ properties }


Example

The following selector represents the last data cell td of a table row tr:

[style.css]

 tr > td:last-of-type{
   color: red;
 }


[index.html]

<body>
  <table>
    <tr>
      <td>1</td>
      <td>2</td>
      <td>3</td>
    </tr>
    <tr>
      <td>4</td>
      <td>5</td>
      <td>6</td>
    </tr>
  </table>
</body>

Css3 selectors last-of-type.png

CSS defines the :last-of-type pseudo-class selector in 6.6.5.9. :last-of-type pseudo-class.