Still don't get the difference between class and id (not in terms of syntax, but why should i use one instead of another) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 7

Still don't get the difference between class and id (not in terms of syntax, but why should i use one instead of another)

pls like 😉😊

14th Oct 2016, 7:40 AM
Baraa AB
Baraa AB - avatar
5 Answers
+ 7
because you can use Class in many elements (no repetition of code) and you may need to distinguish elements with ID
14th Oct 2016, 8:24 AM
Klodian Lula
Klodian Lula - avatar
+ 5
An id is unique (no elements may have the same id), while several elements may have the same class at the same time. An element may also have multiple classes at once. Think of ids as unique names and classes as categories.
14th Oct 2016, 10:04 AM
Zen
Zen - avatar
+ 1
ID is for only one element in the page like footer or header... and class is for repeated things like paragraphs etc..
14th Oct 2016, 7:40 AM
Baraa AB
Baraa AB - avatar
+ 1
thanks a lot all..
14th Oct 2016, 10:55 AM
Baraa AB
Baraa AB - avatar
+ 1
Use 'id's rarely and mostly classes. It helps you to write less. Practice more and you know what I mean.
19th Oct 2016, 4:35 PM
Kevin Heiligtag
Kevin Heiligtag - avatar