0

What is the difference between id and class attribute???

please explain with examples

21st Dec 2017, 2:59 PM
kanthraj s
kanthraj s - avatar
3 Respostas
+ 1
Id is unique, it means that it can't be duplicated. Unlike Id, Class can be duplicated in all your other tags/elements. For example you have: <div class="myClass yourClass" id="myId"></div>, you can still use either myClass or yourClass in your other <div>'s but you can't use it's id to your other <div>'s .
21st Dec 2017, 3:15 PM
Jeric So
Jeric So - avatar
0
when I declared both in same tag what happens??
22nd Dec 2017, 10:27 AM
kanthraj s
kanthraj s - avatar
0
well if you do that, your tag will have an id and class attribute. but if you do that you must not let the value of it's id be the same with the value of it's class.
28th Dec 2017, 2:42 PM
Jeric So
Jeric So - avatar