CSS last-of-type Selector :last-of-type
What is CSS :last-of-type Selector?
CSS :last-of-type selector matches last sibling of its type in child elements of an parent element.
Syntax
General syntax of :last-of-type selector,
element:last-of-type {
property: value;
property: value;
...
}
/* match all last sibling of its type child element */
*:last-of-type {
property: value;
property: value;
...
}
Example
CSS :last-of-type selector select all last sibling of its type child element.
<!DOCTYPE html>
<html>
<head>
<title>CSS :last-of-type Selector</title>
<style>
div :last-of-type {
color: #FF0000;
}
</style>
</head>
<body>
<div>
<span>This is first span</span>
<span>This is second span</span>
<ul>
<li>first item</li>
<li>second item</li>
</ul>
<p>First Paragraph</p>
<p>Second Paragraph</p>
</div>
</body>
</html>
Browser Compatibility
- Google Chrome 2+
- Mozilla Firefox 3+
- Internet Explorer 9+
- Opera 9.5+
- Safari 4+
Note: Here details of browser compatibility with version number may be this is bug and not supported. But recommended to always use latest Web browser.