make css counter works with css selector - HTML CSS CSS

HTML CSS examples for CSS:Selector

Description

make css counter works with css selector

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <style id="compiled-css" type="text/css">
div.primaries<!--  w w w  .ja  va 2 s  .c om-->
 {
   counter-reset:section;
}

div.primaries div.entries>div.meaning:first-child:before {
   counter-increment:section;
   content:counter(section);
}
</style> 
 </head> 
 <body> 
  <div class="primaries"> 
   <div class="headword entries"> 
    <div class="meaning terms"> 
     <span class="meaning terms text">Lorem ipsum dolor sit amet, cons</span> 
    </div> 
    <div class="meaning entries"> 
     <div class="example terms"> 
      <span class="example terms text">Lorem ips<em>Lorem</em> </span> 
     </div> 
    </div> 
    <div class="meaning entries"> 
     <div class="example terms"> 
      <span class="example terms text">Lor<em>Lorem</em>Lorem ipsum dol</span> 
     </div> 
    </div> 
   </div> 
   <div class="headword entries"> 
    <div class="meaning terms"> 
     <span class="meaning terms text">Lorem ipsum dolor sit amet, </span> 
    </div> 
   </div> 
   <div class="headword entries"> 
    <div class="meaning terms"> 
     <span class="meaning terms text">Lorem ipsum dolor sit amet, </span> 
    </div> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials