:last-child

:last-child – pseudo-class | Selectors Level 3

The :last-child selects any element that is last child of its parent.

Syntax

element:last-child {
    style properties
}

Example

The HTML code:

<ul>
    <li>A li element - number 1</li>
    <li>A li element - number 2</li>
    <li>A li element -number 3</li>
</ul>
li:last-child {
    background:#FFB7C5;
}
  • A li element – number 1
  • A li element – number 2
  • A li element -number 3

Related

Resources