When to use id and when to use class?
class is the class for setting the label. It can be used on multiple divs.
id is the identifier for setting the label. It can only be used on one div.
Apply the id to multiple divs in the code. div, the running effect is correct. But I made a mistake in syntax and it cannot pass the W3 verification. But how do you distinguish it when you call the id?
For example, there are so many people in this room, how do you distinguish who is who? The ID is equivalent to a name and an ID card to distinguish who belongs to whom. If two people with the same name (same ID) appear at the same time, who is called and who should respond? In the same way, two names with the same ID defined in CSS will be confused.
Conceptually speaking: id is to find the structure/content first, and then define a style for it; class is to define a style first, and then apply it to multiple structures/content.
We should also maintain good writing status in writing
In some areas such as partitions, navigation, and themes, IDs should be used, for example: #header{... }, id should be used outside the structure as much as possible.
As for class, try to use it within the inner scope of the structure. For example: #header .content{...}