A detailed introduction to the importance of!important in CSS

Source: Internet
Author: User
CSS in the!important is a very important property, sometimes play a very big role, 52css.com this aspect of knowledge is not very much, we look at the following article, it makes a comparative sense of understanding.
A few days ago to write some CSS code when it's hard for me, because that damned IE6 support for the CSS is so bad, I have not noticed before, because things are basically based on IE, but I wrote this blog for the CSS to support more than IE a browser, hateful is I installed Windows 7, this inside is IE8 browser, I think I have no problem, but open IE6, still appear dislocation, so I decided to see IE6 exactly what the situation.
I put all the CSS block all use the bounding box, the results see in IE in the distance between two P is obviously wider than the other browsers, such as you write a P margin property is 20px, then in IE is like 40px, which is why the original accuracy calculation of just good, In IE, but the reason for dislocation.
Later I saw!important this attribute, this property is actually also in the CSS specification, the result IE6 Leng not support, also because it does not support, just let a lot of Csser find the method that solves. In general, in CSS, if the same CSS block is written in the same two of the same properties, it is actually performed according to the bottom, for example:

   1:home{   2:    margin-left:20px;   3:    margin-left:40px;   4:}   5:

Then in the execution of the time is actually performed according to 40px,!important is to let the user set the execution of the statement priority. If you change the above statement to:

1:home{   2:    margin-left:20px!important;   3:    margin-left:40px;   4:}   5:

Then in Firefox, Google Browser and IE7 above will be performed according to 20px, and under IE6 still follow 40px to execute, because IE6 does not support the!important specification, we can follow this rule to meet the IE6 design needs, When you find that IE6 and other browsers display different effects, then set two, in the above one to add the!important tag, and the following sentence does not need to be added, so IE6 follow the following to execute. Senior Csser said: "Today's CSS everywhere!important." This can be the IE6 of the day kill, everyone said IE6 is a lump of metabolic products is not too.

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.