HTML CSS examples for CSS Selector:nth-child
Select the third child from list
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <style id="compiled-css" type="text/css"> .right { background-color:Chartreuse; } .right>img { background-color:yellow; } .right:nth-child(3) { background-color:blue; } </style> <!-- ww w .j a v a 2 s. c o m--> </head> <body> <div class="parent" style="padding-top:5px;"> <div class="right"> line 1 </div> <div class="right"> line 2 </div> <div class="right"> <img src="https://www.java2s.com/style/demo/Safari.png"> </div> <div class="right"> line 4 </div> <div class="right"> line 5 </div> </div> </body> </html>