English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
:last-The child CSS pseudo-class represents the last child element of the parent element.
Complete CSS Selector Reference Manual
Specify the background color of the last p element in the parent element:
!DOCTYPE html <html> <head> <meta charset="utf-8"> <title>Basic Tutorial(oldtoolbag.com)</title> <style> p:last-child { background:orange; } </style> </head> <body> <p>First paragraph.</p> <p>Second paragraph.</p> <p>Third paragraph.</p> </body> </html>Test and see ‹/›
:last-The child selector is used to match the last child element in the parent element.
Hint: p:last-child is equivalent to p:nth-last-child(1)。
The numbers in the table indicate the first browser version that supports this attribute.
Selector | |||||
---|---|---|---|---|---|
:last-child | 4.0 | 9.0 | 3.5 | 3.2 | 9.6 |