:nth-last-child(n)
:nth-last-child(n) selects elements that are the nth from last child(CSS3). The argument is the index of the element. The indexes start at 1.
<!DOCTYPE HTML>
<html>
<head>
<title>Example</title>
<style type="text/css">
body > :nth-last-child(2) {
border: thin black solid;
padding: 4px;
}
</style>
</head>
<body>
<a href="http://java2s.com">Visit the java2s.com</a>
<p>I like <span>HTML</span> and CSS.</p>
<a href="http://java2s.com">Visit the java2s.com</a>
<a href="http://java2s.com">Visit the java2s.com</a>
<p>I like <span>HTML</span> and CSS.</p>
<a href="http://java2s.com">Visit the java2s.com</a>
<a href="http://java2s.com">Visit the java2s.com</a>
<p>I like <span>HTML</span> and CSS.</p>
<a href="http://java2s.com">Visit the java2s.com</a>
</body>
</html>
Home
HTML CSS Book
CSS
HTML CSS Book
CSS
Pseudo Selectors:
- ::first-line Selector
- ::first-letter Selector
- :before Selector
- :after Selector
- CSS Counter Feature
- :root Selector
- Child Selectors
- :first-child Selector
- :last-child Selector
- :only-child Selector
- :only-of-type selector
- :nth-child(n)
- :nth-last-child(n)
- :nth-of-type(n)
- :nth-last-of-type(n)
- Enabled Elements with :enabled
- Disabled Elements with :disabled
- Checked Elements with :check
- Default Elements with :default
- Valid Elements with :valid
- Invalid input Elements with :invalid
- :in-range selector
- :out-of-range selector
- :required selector
- :optional selector
- :link selector matches hyperlinks.
- :visited selector matches visited hyperlinks.
- :hover Selector
- :active Selector
- :focus Selector
- Negation Selector not
- :empty Selector
- :lang Selector
- :target Selector
Related: