We know that when defining a style in a style sheet, you can define an id or a class, for example:
ID method: #test{color:#333333}, call the content in the page
CLASS method: .test{color:#333333}, call the content in the page
id can only be used once on a page, and class can be referenced multiple times.
Some netizens asked, there seems to be no difference between id and class. I used multiple ids on the page and it was displayed normally in IE. Is there any impact of using multiple ids?
Answer: The first impact is that it cannot pass W3 verification.
In terms of page display, current browsers still allow you to make this mistake, and using multiple identical IDs can "generally" display normally. But when you need to use JavaScript to control this div through id, an error will occur.
id is a tag used to distinguish different structures and contents, just like your name. If there are two people in a room with the same name, there will be confusion;
class is a style that can be applied to any structure and In terms of content, it is like a piece of clothing;
is conceptually different:
id first finds the structure/content and then defines a style for it; class defines a style first and then applies it to multiple structure/content.
Web standards hope that everyone uses strict habits to write code,
For example: you can use bold or display, but W3C recommends that you use it because it is more semantic
If you don’t pay attention to these details and think it doesn’t matter,
then there is no need for you to transition to XML, and there is no need to learn web standards, because the application of web standards starts from changes in these small details, otherwise Isn’t it possible to use current html?