:nth-last-child
:nth-last-child is a CSS pseudo-class in the Pseudo-classes category. Selects elements by position counting from the end. The syntax is :nth-last-child(<n>). A typical example: li:nth-last-child(-n+3) { color: gold; } It is commonly applied to markup such as <div class="demo">Sample</div> Browser support: Chrome 1+, Firefox 1+, Safari 1+, Edge 12+. A close relative is :hover, which applies styles when the user hovers over an element with a pointing device. A close relative is :focus, which applies styles when an element has received focus. A close relative is :active, which applies styles while an element is being activated (clicked). More about this category: CSS pseudo-classes for targeting elements based on state or position. Related Pseudo-classes entries: :hover, :focus, :active, :visited, :link, :focus-within, :focus-visible, :target. This page is part of the free CSS Reference documentation covering 841+ properties, selectors, functions, and at-rules, each with syntax, values, examples, and browser support.