CSS Selector :last-of-type








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

Summary

CSS Version
3

CSS Syntax

:last-of-type {
   style properties 
}

Browser compatibility

:last-of-type Yes 9.0 Yes Yes Yes




Example

An example showing how to use :last-of-type CSS selector.

<!DOCTYPE html>
<html>
<head>
<style> 
p:last-of-type{<!--from   ww w. ja  va 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