What is the key difference between ID selector and CLASS selector? | Sololearn: Learn to code for FREE!
+ 1

What is the key difference between ID selector and CLASS selector?

26th Mar 2017, 9:29 AM
sujan gaha
sujan gaha - avatar
3 Answers
+ 4
id="myid1 myid2 " is wrong ××××× class="cls1 cls2 cls2" possible √√√
26th Mar 2017, 10:15 AM
Abdel
Abdel - avatar
+ 1
An id should be used once and classes can be used as many time as you need .
26th Mar 2017, 10:13 AM
Abdel
Abdel - avatar
0
ID selector can only be used once in an HTML document while CLASS selector can be assigned to more than one elements in an HTML document. You can assign more than one class to an element but you can only assigned one ID to an element. ID selector is defined in CSS with the # sign example #ID while CLASS selector is defined in CSS with the period (.) sign example .CLASS I hope this explains it
27th Mar 2017, 9:26 PM
Hassan Sani
Hassan Sani - avatar