What is Class and What is ID?

 Posted by Prudhvisagar on 1/23/2015 | Category: HTML 5 Interview questions | Views: 1051 | Points: 40

A Class is style that can be applied to one or more HTML elements.Classes are defined in CSS using a period followed by the Class name.By Class selector are defined with the ".(dot)".
The following snippet shows a class defined,and then it being applied to an HTML div element.


{font-family:'Times New Roman';

<div class="class1" ><p>dotnetfunda</p></div>

An ID selector is a name assigned to a specific style.It can be associated with one HTML element with the assign ID.By ID selector are defined with the "#" character followed by the selector name.

#id1 {

background-color: blue;

<div id="id1">it funda</div>

Source: Learning | Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response

More Interview Questions by Prudhvisagar