+ 2

When can we use class ?

18th Feb 2018, 10:27 AM
Lucifer
Lucifer - avatar
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
18th Feb 2018, 10:49 AM
Augustinas Lukauskas
Augustinas Lukauskas - avatar
+ 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.
18th Feb 2018, 11:06 AM
Sachin Artani
Sachin Artani - avatar