What is the difference between ID and class? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What is the difference between ID and class?

if possible tell me in which condition these tag are used.

21st Jun 2018, 11:25 PM
Manoj Neupane
Manoj Neupane - avatar
5 Answers
+ 5
id: Its used for set to an element an identification unique in entire HTML tree. Can exist ONLY one element with same id and any element can has at max ONE id class: Its used for describe an set of element that share common properties. Any class can be associated to MULTIPLE elements and any element can belong to MULTIPLE class
21st Jun 2018, 11:38 PM
KrOW
KrOW - avatar
+ 2
Mean that cannot exists different elements with same id and any element can has max one id
21st Jun 2018, 11:43 PM
KrOW
KrOW - avatar
+ 2
got it. many many thanks 😊😊
21st Jun 2018, 11:44 PM
Manoj Neupane
Manoj Neupane - avatar
+ 2
👍👍😁
21st Jun 2018, 11:44 PM
KrOW
KrOW - avatar
+ 1
it means we can use id multiple times but only to specific element.
21st Jun 2018, 11:41 PM
Manoj Neupane
Manoj Neupane - avatar