HTML CSS examples for CSS Selector:last-of-type
The :last-of-type selector selects element that is the last child of a particular type inside its parent.
It is the same as :nth-last-of-type(1).
Select the last <p> element of its parent:
<!DOCTYPE html> <html> <head> <style> p:last-of-type {<!-- w ww .ja v a 2s .c o m--> background: #ff0000; } </style> </head> <body> <h1>This is a heading</h1> <p>The first paragraph.</p> <p>The second paragraph.</p> <p>The third paragraph.</p> <p>The fourth paragraph.</p> <div> <h1>This is a heading</h1> <p>The first paragraph.</p> <p>The second paragraph.</p> <p>The third paragraph.</p> <p>The fourth paragraph.</p> </div> </body> </html>