:last-child
Summary
The :last-child pseudo-class represents the last child element of its parent.
Examples
/*We add some red color to the second list item*/
li:last-child {
color: red;
}
<ul>
<li>I'm not red!</li>
<li>I'm red!</li>
</ul>
Notes
Remarks
The :last-child pseudo-class is a structural pseudo-class. Structural pseudo-classes enable selection based on extra information in the document tree that can’t be selected using simple selectors or combinators.
Syntax
selector
- last-child
- selector
- A CSS simple selector.
Standards information
- Selectors Level 3, Section 6.6.5.7
Related specifications
- CSS Selectors Level 3
- W3C Recommendation
See also
Related pages
Reference
- :root:root
- :nth-child:nth-child
- :nth-last-child:nth-last-child
- :nth-of-type:nth-of-type
- :nth-last-of-type:nth-last-of-type
- :first-of-type:first-of-type
- :last-of-type:last-of-type
- :only-child:only-child
- :only-of-type:only-of-type
- :empty:empty
Attributions
Microsoft Developer Network: [Windows Internet Explorer API reference Article]