Use Same class for multiples divs and differents colors - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Color

Description

Use Same class for multiples divs and differents colors

Demo Code

ResultView the demo in separate window

<html lang="en">
 <head> 
  <style>

.genericClass{<!--  w w  w  .ja v a 2 s.  c o  m-->
   padding: 5px;
   font-family: Arial;
   font-size: 12px;
}
.bg1{
   background-color: #000; //this should be the first
}
.bg2{
   background-color: #FFF; //this should be the second
}
.bg3{
   background-color: #B1B; //this should be the third
}
.bg4{
   background-color: #DDD; //this should be the fourth
}


      </style> 
 </head> 
 <body translate="no"> 
  <div class="genericClass bg1">
    Some Text 
  </div> 
  <div class="genericClass bg2">
    Some Text 
  </div> 
  <div class="genericClass bg3">
    Some Text 
  </div> 
  <div class="genericClass bg4">
    Some Text 
  </div> 
 </body>
</html>

Related Tutorials