HTML CSS examples for CSS Selector:element parent child
Select first child with given class
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <style id="compiled-css" type="text/css"> li[class="class1"] { background-color:Chartreuse; } li[class="class1"]~li[class="class1"] { background-color:yellow; } </style> <!-- w w w . j a va2 s. c o m--> </head> <body> <ul> <li class="class1">Lorem ip</li> <li class="class1 class2">Lor</li> <li class="class1">Lor</li> </ul> <ul> <li class="class1 class2">Lor</li> <li class="class1">Lorem ip</li> <li class="class1">Lor</li> </ul> <ul> <li>Lor</li> <li class="class1">Lorem ip</li> <li class="class1">Lor</li> </ul> </body> </html>