Set Background color property for div - HTML CSS CSS Property

HTML CSS examples for CSS Property:background-color

Description

Set Background color property for div

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">

.outer-container {<!-- ww w  .j a v a2s.  c o m-->
   width: 100%;
}

.outer-container .main-container {
   width: 980px;
   margin: 0 auto;
   height: 100px;
}

.blue .main-container {
   background: blue;
}

.green .main-container {
   background: green;
}

.red .main-container {
   background: red;
}


      </style> 
 </head> 
 <body> 
  <div class="outer-container blue"> 
   <div class="main-container"></div> 
  </div> 
  <div class="outer-container green"> 
   <div class="main-container"></div> 
  </div> 
  <div class="outer-container red"> 
   <div class="main-container"></div> 
  </div>  
 </body>
</html>

Related Tutorials