Home HTML/CSS CSS 3 :last-child - Definition and Usage
Author:

The :last-child selector is used to select the specified selector, only if it is the last child of its parent.

Example:

- Select and style the last child element of every <ul> element:

ul>:last-child { background:#000; }

- Select and style the last <li> element in lists:

li:last-child {background:#A40003;}

- Select and style every <p> element that is the last child of its parent:

p:last-child { background-color:#999;} 

The :last-child selector is supported only in Mozilla Firefox 4 browser.

Did you like this tip 

Beside that, you can use :last-of-type selector to matches every element that is the last child of its parent.

p:last-of-type { background:#000; }



Comments (0)
Write comment
Your Contact Details:
Comment:
Security
Please input the anti-spam code that you can read in the image.

"