A Class is used to define one or more elements based on user-defined criteria. A more appropriate analogy is a script: a Class can define the story line of each character in the script. You can use this class through CSS, Javascript, etc. Therefore, you can use class="Frodo", class="Gandalf", class="Aragorn" on a page to distinguish different story lines. Another very important point is that you can use Class any number of times in a document.
As for ID, it is usually used to define a tag that only appears once on the page. When making a structured layout for page layout (for example, a page usually consists of a header, a
It can be summed up in one sentence: Class can be used repeatedly but ID can only be used once in a page. It is possible that using the same ID repeatedly will not cause problems in most browsers, but this is definitely an incorrect use according to the standard, and may cause real-life problems in some browsers. (I just tried it in Dreamweaver, and indeed, there was no error)
In actual application, Class may be more useful for text layout, etc., while ID is more useful for macro layout and design placement of various elements. it works.