Helper House (Bkjia.com) TutorialA friend asked me about the difference between the id and class defined in web standards on the forum today. A: There must be duplicates. For example.
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Tip: the code can be modified before running!
Problem Analysis:
I. duplicate IDs are not allowed in web standards. For example, div ID = "aa" cannot be repeated twice, while class defines classes, which can be infinitely repeated in theory, in this way, you can use the definition that requires multiple references.
2. the attribute priority problem ID has a higher priority than the class. See the example above.
III. convenience for JS and other client scripts. If you want to perform script operations on an object on the page, you can define an ID for it. Otherwise, you can only find it by traversing the page element and adding specific attributes, this is a relatively time-consuming resource, which is far less simple than an ID.