First, we will introduce the differences between id and class:
1. id is a label used to distinguish between different structures and content. id is to first locate the structure/content and then define the style. class is a style, it can be applied to any structure or content. class defines a style and then applies it to multiple structures or contents.
2. id is the element name, which can be accessed by js or other script programs, and class is the css class Name of the element.
3. When defining a style, use # aa {...} for id = "aa" and use. bb {...} For class = "bb {...}.
4. class is a global attribute, and id is a local attribute.
The following code is displayed:
<Div id = "aa" class = "bb"> test </div>
# Aa {width: 300px; height: 50px; background-color: Red ;}
. Bb {width: 100px; height: 300px; background-color: blue ;}
How can this problem be displayed?
The answer is: display as a test text block with a width of 300, a height of 50, and a red background. Because the class is a global attribute and the id is a local attribute, the display style is that after the class defines this attribute, the newly defined attribute of id is added. When the class and id attributes are repeated, take the attributes of id. It is similar to the parent-child inheritance relationship in programming.