CSS style ID and class attribute precedence issues

Source: Internet
Author: User

When designing a Web page in Div+css, there are always some CSS property precedence issues to encounter.  If you do not know the priority level, it is easy to assume that it should be. Here to analyze a problem I encountered, to learn about the attribute priority problem.

Here is the code test code:

<style type= "Text/css" >
<!–
#div1 ul li{List-style:square;}
. div2class ul li{List-style:none;}
–>
</style>
<div id= "Div1" class= "Div1class" >
<div id= "Div2" class= "Div2class" >
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
</ul>
</div>
</div>

The above code is intended to remove the points that are defined by Li by Div2class, and the higher the priority, the more it should be the application. Div2class in the definition, but the actual point is not removed.  is not applied. Div2class is also displayed as a setting in the #div1. This proves that the ID priority is higher than class.

A little bit of experience is that the property ID passed through the inheritance takes precedence over class

CSS priority order: Style > ID > Class > Tag > Inherited properties in the same order in tag

Original article reproduced please indicate the source: unstoppable [http://www.dengor.com/archives/618.html]

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.