+ 1

Why was class used here instead of id

Hello, so I am in the process of still learning web development and something that I just can not grasp the idea of is Id and classes. I have been watching Traversy media YouTube and have learned a lot but in one of his videos I do not know why he used class instead of Id for certain things. Here is the link to the code I am talking about. https://codepen.io/bradtraversy/pen/jvKmjB For example: for logo he used a class but I thought classes are more for a general use (when wanting multiple things to be the same in that class) while Id is for something specific. Because he is just editing the logo should the logo not be a id then? I would really appreciate if someone can explain the code (linked above) and why class is chose instead of Ids and maybe some more explanations of when to use a class vs Id Thankyou everyone I hope I explained well enough and I hope you all have a great day! :D

20th Apr 2020, 7:26 AM
2 Answers
+ 2
remember that id is unique..no elements can have same id and one element only can have one id.. class is not unique,multiple elements can use same class,and one element can have many classes so if u want to style multiple elements with same style,u can use class but still it depends on what favor u the most
20th Apr 2020, 7:42 AM
Lily Mea
Lily Mea - avatar
thats what i thought but for some things i still dont get why he used it, for example his logo could be unique but class was used instead. also thankyou for your response!
20th Apr 2020, 4:26 PM