Answer: 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.
Ex:
.class1
{font-family:'Times New Roman';
background-color:red;
font-size:20px;
}
<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.
Ex:
#id1 {
background-color: blue;
}
<div id="id1">it funda</div>
Source: Learning | Asked In: Many Interviews |
Alert Moderator