:last-of-type CSS Pseudo Class


The :last-of-type pseudo-class is a selector in CSS (Cascading Style Sheets) that allows you to target the last element of a specific type within its parent element. It is used to apply styles to the final element of a particular type within a container, such as the last paragraph in a div or the last list item in an unordered or ordered list.

Here's a simple example of how you might use the :last-of-type pseudo-class in CSS:

p:last-of-type {
font-weight: bold;
color: blue;

In this example, all the last paragraphs (<p>) within their respective parent containers will have their text made bold and colored blue.

This pseudo-class is helpful for applying distinct styling to the last occurrence of an element type without needing to add specific classes or IDs to those elements.


:last-of-type {
  /* ... */


<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,</p>
<p>quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident,</p>
<p>sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
p:last-of-type { 
font-style: italic;
color: #3e79f9;

Browser Support

The following table will show you the current browser support for the CSS :last-of-type pseudo class.

Edge Chrome Firefox Opera Safari
Tablets / Mobile
Chrome Firefox Opera Safari Samsung Webview

Last updated by CSSPortal on: 1st October 2023