[Import] How do I determine the CSS priority?

Source: Internet
Author: User

<! 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.