:last-child Selector
The :last-child selector selects the last child element.
<!DOCTYPE HTML>
<html>
<head>
<title>Example</title>
<style type="text/css">
:last-child {
border: thin black solid;
padding: 4px;
}
</style>
</head>
<body>
<p>I like <span>HTML</span> and <span>CSS</span>.</p>
<a href="http://java2s.com">Visit java2s.com</a>
</body>
</html>
The body element is the last child of the html element and is matched by the selector.
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: