+ 2
When can we use class ?
2 Answers
+ 4
You can use class (and also id) attributes to "mark" any HTML element. Its purpose is to make it easier to select elements with CSS and JavaScript afterwards. If you don't use CSS or JS, class attribute is not very useful
+ 4
Class in HTML is an element's attribute. It can be used like-
<p class="myclass">This is a para</p>
And then the definition of myclass is defined in CSS. eg.
.myclass {
color: blue;
}
. (dot or period) is used to represent a class in CSS.