HTML CSS examples for CSS Selector:class
With CSS only: Select first occurrence of class throughout whole document
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <style id="compiled-css" type="text/css"> div.inner>.copyright { display:none; } div.inner:first-child .copyright { display:block; background:Chartreuse; } </style> <!-- ww w. j a v a 2 s . com--> </head> <body> <div class="outer"> <div class="inner"> <div class="content"> Lorem </div> <div class="copyright"> Lorem </div> <!--// DISPLAY THIS ONE //--> </div> <div class="inner"> <div class="content"> Lorem </div> <div class="content"> Lorem </div> <div class="content"> Lorem </div> <div class="copyright"> Lorem </div> </div> <div class="inner"> <div class="content"> Lorem </div> <div class="content"> Lorem </div> <div class="copyright"> Lorem </div> </div> </div> </body> </html>