Get your own website Result Size: 625 x 565
x
 
<!DOCTYPE html>
<html>
<head>
<style> 
p:last-child {
  background-color: yellow;
}
li:last-child {
  background-color: yellow;
}
</style>
</head>
<body>
<h1>Demo of :last-child</h1>
<p>The first paragraph.</p>
<p>The second paragraph.</p>
<p>The third paragraph.</p>
<p>The fourth paragraph.</p>
<div>
<p>The first paragraph in a div.</p>
<p>The second paragraph in a div.</p>
<p>The third paragraph in a div.</p>
<p>The fourth paragraph in a div.</p>
</div>
<ul>
  <li>First list item</li>
  <li>Second list item</li>
  <li>Third list item</li>
</ul>
</body>
</html>