class is the class that sets the label.
id is the identifier of the set label.
The class attribute is used to specify which style class the element belongs to.
For example, a style sheet can be added:
.baobao { color: lime; background: #ff80c0 }
Usage: class="baobao"
The id attribute is used to define a unique style for an element. Such as a CSS rule:
#binbin { font-size: larger }
Usage: id="binbin"
ID is a label used to distinguish different structures and contents, just like your name. If there are two people with the same name in a room, confusion will occur;
Class is a style that can be applied to any structure and content, just like a piece of clothing;
Conceptually speaking, they are different: id finds the structure/content first, and then defines a style for it; class defines a style first, and then applies it to multiple structures/content.
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. So 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 mark that appears only once on the page. When performing a structured layout for page layout (for example, a page usually consists of a header, a masthead <masthead>, a content area and a footer, etc.), it is generally ideal to use ID, because an ID is in a Can only be used once in the document. These elements rarely appear more than once on the same page.
To sum it 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.
In practical applications, Class may be more useful for text layout, etc., while ID is more useful for macro layout and design placement of various elements.