What is the difference between specifying css class with # and .? i.e. #Class1 or .Class1?

 Posted by Virendradugar on 12/28/2009 | Category: CSS 3 Interview questions | Views: 7052
Answer:

Stylesheeet class declared with # applies to items which have same Id value as of the class name.

like

#div1

{
font-weight:bold;
}

<div id="div1">Styled Container</div>


Where css class declared with . can be used for any html element.

.class1

{
position:relative;
left:50px;
}

<div class="class1">Styled Container</div>


Thanks,
Virendra Dugar


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response