CSS Selector :last-of-type

Description

The :last-of-type selector selects every element that is the last child of a particular type from its parent.

Example


<!DOCTYPE html>
<html>
<head>
<style> 
p:last-of-type{<!--from  ww  w .j av a 2s.  c o m-->
   background:gray;
}
</style>
</head>
<body>
    <p>The first paragraph.</p>
    <p>The second paragraph.</p>
    <p>The third paragraph.</p>
    <p>The fourth paragraph.</p>
</body>
</html>

Click to view the demo

The code above generates the following result.

:last-of-type




















Home »
  HTML CSS »
    HTML CSS Reference »




HTML Tag Reference
CSS Reference
CSS Selector Reference
Encoding Reference