nth childs

what are the rules for the children access in CSS

by iamanubhavsaini

HTML

<div>
    <p>ad</p>
    <p>ad</p>
<span>first</span>
<span>second</span>
<span>..</span>
<span>last</span>
</div>

CSS

/*this is for canary*/
/*div:last-child{color:red;} makes all of them red */

/*div::lasst-child{color:red;} doesn't work at all 

div:last-child(span){color:red;}

div:first-child{color:red;

div span:first-child{color:red;}
but what works is this:

*/

div span:last-child{color:blue;}
div p:first-child{color:red;}

JavaScript

//