use first-child selector for a certain class - HTML CSS CSS Selector

HTML CSS examples for CSS Selector:element parent child

Description

use first-child selector for a certain class

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:first-of-type {
   background-color:Chartreuse;
   border:5px solid yellow;
}

.teste:nth-child(2) {<!--  w w w.  j  a  v a 2 s. c  o  m-->
   background-color:blue;
}
</style> 
 </head> 
 <body> 
  <div>
    Lorem ips 
  </div> 
  <div class="teste">
    Lorem ips 
  </div> 
  <div class="teste">
    Lorem ips 
  </div> 
  <div class="teste">
    Lorem ips 
  </div>  
 </body>
</html>

Related Tutorials