+ 2

What is the difference between class and id in html?

9th Sep 2019, 7:48 AM
takeru
takeru - avatar
3 Answers
+ 13
You can use "many" same class name in in different elements in one webpage while you can only use "one" unique ID name. If you want to ID another part of the website, use another name.
9th Sep 2019, 3:52 PM
MCGAmedCoder gamerArtist
MCGAmedCoder gamerArtist - avatar
+ 11
Id is more specific than class. Multiple classes can be added to an element, but only one Id for each element Also, class selectors are started with a ". " in CSS, while "#" is used for Id. Example, HTML : <div id="div1" class="div">Some text</div> CSS : #div1 { background-color: blue; } . div { font-weight: bold; }
9th Sep 2019, 8:08 AM
Oma
Oma - avatar