<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <br/> <HTML xmlns = "http://www.w3.org/1999/xhtml"> <br/> <pead> <br/> <title> new document </title> <br/> <meta name = "generator" content = "editplus"/> <br/> <meta name = "author" content = ""/> <br/> <meta name = "keywords" content = ""/> <br/> <meta name = "Description" content =" "/> <br/> <style type =" text/CSS "> <br/> body {<br/> background-color: white; <br/> color: black; <br/>}< br/> H1 <br/>{< br/> background-color: blue; <br/> color: red; <br/>}< br/> em <br/>{< br/> background-color: green; color: black; <br/>}< br/> # Serious {color: Blue ;}< br/>. yahoo {color: black; Background-color: yellow ;}< br/># serious {color: red ;} <br/> H1 em <br/>{< br/> color: lime; <br/>}< br/> </style> <br/> </pead> <br/> <body> <br/> <em id = "serious" Class = "yahoo"> Yahoo </em> <br/> </body> <br/> </ptml> <br/>
<Em id = "serious" class = "yahoo"> Yahoo </em>
The EM tag defines an ID selector, class selector, and type selector.
Run the precedingCodeAnd found:
The background-color of the EM tag applies the background-color attribute in the Yahoo class selector.
While color applies the second attribute # attributes of the serious ID selector.
How is the priority defined?
Id selector (for example, # divmain {})> class (for example,. divspecial {})> label (for example, body {})
When the defined attributes conflict, the last defined attribute prevails.
ArticleSource: http://www.lemongtree.com/Archives/727.aspx