256 of 313 menu

The last-of-type pseudo-class

The last-of-type pseudo-class selects the element that is the last child of a parent of a given type. That is, if I'll write h2:last-of-type - the last h2 in the parent will be found (unlike last-child, which will find only the h2 that is the very last in the parent).

Syntax

selector:last-of-type { }

Example

Let's find the paragraph that is the last paragraph in the parent:

<div> <h2>header</h2> <p>paragraph</p> <h2>header</h2> <p>paragraph</p> <h2>header</h2> <p>paragraph</p> </div> h2:last-of-type { color: red; }

:

English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline