x
 
<!DOCTYPE html>
<html>
<head>
<style> 
p:last-of-type {
  background-color: yellow;
}
li:last-of-type {
  background-color: yellow;
}
</style>
</head>
<body>
<h1>:last-of-type 伪类演示</h1>
<p>第一个段落。</p>
<p>第二个段落。</p>
<p>第三个段落。</p>
<p>第四个段落(同类型中的最后一个)。</p>
<div>
<p>div 中的第一个段落。</p>
<p>div 中的第二个段落。</p>
<p>div 中的第三个段落。</p>
<p>div 中的第四个段落(同类型中的最后一个)。</p>
</div>
<ul>
  <li>第一个列表项</li>
  <li>第二个列表项</li>
  <li>第三个列表项(同类型中的最后一个)</li>
</ul>
</body>
</html>