css first child second child code example
Example 1: css first child
:first-child {
//styles here
}
:nth-child(1) { //the benefit of this is you can do it for 2nd, 3rd etc...
//styles here
}
Example 2: nth-child() css
/* Selects the second <li> element in a list */
li:nth-child(2) {
color: lime;
}
/* Selects every fourth element
among any group of siblings */
:nth-child(4n) {
color: lime;
}
Example 3: select even child css
li:nth-child(even) { /* Selects only even elements */
color: green;
}
Example 4: css first child
/*CSS First - forth child*/
:first-child {}
:nth-child(2){}
:nth-child(3){}
:nth-child(4){}