+ 1

What is the main difference between id and class attribute?

10th Jul 2017, 7:44 PM
Arun Kumar N
Arun Kumar N - avatar
4 odpowiedzi
+ 1
It can be more than one element with the same class, but you can only have one element per id
10th Jul 2017, 8:33 PM
Andrés04_ve
Andrés04_ve - avatar
+ 1
ID is for an individual element. CLASS is something you can place on multiple elements, and they'll all be affected by the class definition. With that being said, you can have an element that has an ID set, and then is part of multiple classes. You can call that individual element by its ID, or you can refer to all elements of a class by using its CLASS name.
10th Jul 2017, 7:46 PM
AgentSmith
+ 1
@Netkos Ent How about document.all("id of htmlelement")? document.all select multiple elements which have same id attribute
10th Jul 2017, 8:04 PM
Yanothai Chaitawat
Yanothai Chaitawat - avatar
+ 1
Sorry, didn't notice reply until now. You can manipulate the elements in that manner, but that approach is why we created classes, as I'm sure you can figure out the implications that come along with going about it that way.
10th Jul 2017, 8:10 PM
AgentSmith