A div is like a blank container. To set the properties of a div, we’ll associate it a class or an id and then set the properties for that class / id.


If we want to use the properties on more than one div, we’ll use classes. Otherwise, we’ll use ids.


In the CSS file, class names start with . while ids names start with #.


Using classes:
  • in the HTML file
    Code:
    <div class = "common">
            ... div's content ...
    </div>
  • in the CSS file
    Code:
    .common
    {
    	color : blue;
    }




Using ids:
  • in the HTML file
    Code:
    <div id = "unique">
            ... div's content ...
    </div>
  • in the CSS file
    Code:
    #unique
    {
    	color : blue;
    }