CSS! Use of important

Source: Internet
Author: User

This articleArticleUse the latest ie10 and Firefox and chrome tests (as of 22:23:22, January 1, May 27, 2013)

CSS principles:

As we know, CSS writes in different places have different priorities. definitions in the. CSS file <attributes in the element style, but if they are used! Important, things will become different.

First, let's take a look at the following section.Code:

 <!  Doctype   Html  >  <  Html  >  <  Head  >  <  Meta   HTTP-equiv  = "Content-Type"  Content  = "Text/html; charsets = UTF-8"  >  <  Title  > Test CSS! Important differences </  Title  >   </  Head  >   <  Style   Type  = "Text/CSS"  > . Testclass {color: Blue! Important ;} </  Style >  <  Body  >      <  Div   Class  = "Testclass"   Style  = "Color: red ;"  > Test important in CSS </  Div  >  </  Body  >  </  Html  > 

Although the element style has the testclass class definition, it is used in the CSS definition above! Important defined the highest priority, whether in ie6-10 or Firefox and chrome are consistent, show blue.

This also indicates that IE6 can be identified! Important, but this is a defect of ie6. IE6 cannot recognize the following styles:

 
. Testclass {color: Blue! Important; color: red ;}

In this way, the display in IE6 will be red.

Of course, you can also identify IE6 in the following ways:

. Testclass {

Color: Blue! Important;

}

. Testclass {

Color: red;

}

The above method also enables IE6 to be displayed in blue.

The above example is used! The CSS definition of important has the highest priority. There is only a small bug in IE6. Note that writing methods can be easily avoided.

 

 

 

 

 

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.