Class vs. Id in CSS

by Rekha 2010-03-30 18:31:45

Class vs. Id

Use an Id for elements that are used once and only once on a page

The HTML:
<div id="content"></div>



The CSS:

#content {background: #fff}



Use a class for elements that may be reused on the page

The HTML:
<p class="large-text">
</p>


The CSS:
.large-text {font-size: 1.4em}





Tagged in:

814
like
0
dislike
0
mail
flag

You must LOGIN to add comments