<! DOCTYPE HTML Public"-//W3C//DTD XHTML 1.0 strict//en" "HTTP://WWW.W3.ORG/TR/XHTML1/DTD/XHTML1-STRICT.DTD"> "http://www.w3.org/1999/xhtml"xml:lang="ZH"lang="ZH"> "http://www.w3.org/2000/08/w3c-synd/#"> <meta http-equiv="Content-language"Content="ZH-CN"/> <meta http-equiv="Content-type"Content="text/html;charset=gb2312"/> <title>blueidea</title> <style type="Text/css">/*<! [Cdata[*/#aa {color:red}. aa {Color:blue}/*]]>*/</style> "AA" class="AA">aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</div> </body> <! DOCTYPE HTML Public"-//W3C//DTD XHTML 1.0 strict//en" "HTTP://WWW.W3.ORG/TR/XHTML1/DTD/XHTML1-STRICT.DTD">"http://www.w3.org/1999/xhtml"xml:lang="ZH"lang="ZH">"http://www.w3.org/2000/08/w3c-synd/#"><meta http-equiv="Content-language"Content="ZH-CN"/><meta http-equiv="Content-type"Content="text/html;charset=gb2312"/><title>blueidea</title><style type="Text/css">/*<! [Cdata[*/. A {color:orange}.b {background: #eee}.c {border:1px solid red}/*]]>*/</style>class="a b c">aaaaaaaa</div></body>One.
The Web Standard is not allowed to duplicate ID, such as div id= "AA" a page is not allowed to repeat 2 times, and class is defined as classes, theoretically can be infinitely repeated, so that the definition of multiple references can be used.
The
Class can also refer to multiple classes at the same time, separated by a space between different classes.
Two.
property priority problem, ID priority is higher than class, see above example
three.
Convenient JS and other client-side script, if you want to script an object in the page, then you can define an ID, otherwise only use traverse page element plus specify specific attributes to find it, it is relatively wasteful time resources, far less than a simple ID.