Log in

View Full Version : how to use nth-child classes ?



drwebsites
05-15-2014, 02:53 AM
HI Guys !!!

Can anybody tell me how to use first-child, last-child and nth-child classes ??

Thanks in advance

Sherin
05-14-2019, 01:51 AM
To use First child classes::
Here first child will be colored red.

li:first-child {
color:red;
}

To use Last child classes::
Here last child will be colored red.

li:last-child {
color:red;
}

To use nth child classes::
Here all multiples of 2(like 2,4,6,8...) will be colored red.

li:nth-child(2n){
color:red;
}

Here mentioned child(like here 5th child) will be colored red.

li:nth-child(5){
color:red;
}