0
What is the actual difference between ID and Class selectors in CSS when used practically?
I have been struggling to get the difference b/w these two selectors. Upon searching I found that the ID selector is only for a particular element and CLASS can be used on multiple elements, but I was able to use the ID selector on multiple html elements. Needed a bit more clarity in this. Thanks in advance.
2 Antworten
+ 3
The web browser tolerates a lot of bad code, but you should NOT use the same ID on multiple elements of the same page. It should be the unique identifier of a single element.
On the other hand, class is perfectly suitable to style many elements, potentially even different types of elements, at the same time.
+ 1
Thanks for the clarification mate.