CSS :last-child Selector

❮ Previous Selectors Next ❯

Example

p:last-child {
  background: red;
}

Meaning

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

Version: CSS3




Standard Syntax

:last-child {
  css declarations;
}



Browser Support

The numbers in the table specify the first browser version that fully supports the property.




Status







More Example

Example

ul li:last-child {
  border: 1px solid red;
  color: red;
}
❮ Previous Selectors Next ❯