+ 1

Difference between id and class in html, does it affect the attributes?

html css js

21st Apr 2017, 12:30 PM
Swami
Swami - avatar
4 Respostas
+ 12
In short: ID is used for a single element, Class is used for multiple element. Generally... they are used for CSS and JS.
21st Apr 2017, 12:33 PM
Maz
Maz - avatar
+ 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.
21st Apr 2017, 12:53 PM
Bebida Roja
Bebida Roja - avatar
+ 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
21st Apr 2017, 12:39 PM
hkchakladar
hkchakladar - avatar
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.
21st Apr 2017, 4:32 PM
Celso Matule
Celso Matule - avatar