+ 1
Difference between id and class in html, does it affect the attributes?
html css js
4 odpowiedzi
+ 12
In short:
ID is used for a single element,
Class is used for multiple element.
Generally... they are used for CSS and JS.
+ 2
Another difference -well not difference but a consequence- is that getElementById can only get one element wereas getElementByClassName can get as many as you have.
+ 1
`id` can be used for once in a webpage, while `class` can be used in many places in same webpage.
These are used for CSS
0
ID is used for single elements inn case u want to something only for that div and
Class is used for multiple elements, I mean many divs.