0

[HTML] When do I use .class and when do I use #id?

for example, I know that for div elements it is better to use class, <div class="a">...</div> why didn't we use id? why <p id="b"> and not <p class="b">?

20th Dec 2022, 4:19 AM
Ahmad Sulaiman
2 Answers
+ 3
Id is used to refference a specific element, whereas class can be used to reference a defined group of elements for example a class of headings where all the headings belong to a specific class. Elements can also belong to more than one class.
20th Dec 2022, 6:05 AM
Jerry