Summary of usage of!important in CSS

Source: Internet
Author: User

 <! DOCTYPE HTML public  -//w3c//dtd XHTML 1.0 transitional//en   "  HTTP://WWW.W3.ORG/TR/XHTML1/DTD/XHTML1-TRANSITIONAL.DTD   > < HTML Xmlns= " http://www.w3.org/1999/xhtml  "  >  content-type  "  Content= " text/html; charset=utf-8  " / > <title> Untitled Documents </title> <style> <!--! important only Ie7.0 and Firefox can be identified, but Ie6.0 cannot be applied successfully. Important elevation priority (or as forced redefinition--

<!--! Important is the syntax defined by CSS1, which is to improve the application priority of the specified style rule (see: W3.org's explanation).
The syntax format {srule!important}, which is written in the last face of the definition, for example: box {color:red!important;}
If we define a style like this:
#box {background-color: #ffffff! important; background-color: #000000
 


--#box div {color:red;}. important_false {color:blue;}. important_true {Color:blue!  Important } #box2 {background-color: #cccccc!important; Background-color: #000000
 
<!--Firefox: The following paragraph is red if placed on top, and blue if placed at the bottom. The
indicates that if placed on top, #box div overrides #idcolor, this is the priority of the ID. The
and. Important_false's class priority is less than the ID and does not overwrite the #box div.
if placed at the bottom, the #idcolor is not overwritten. Important_false.
If id= "Idcolor" is not set, it is blue. The
description. Important_false covers the #box div IE7: #idColor放在最下面, it's red. The
is placed at the bottom and is red, removing the id attribute. It's red, too.
No description is overwritten
#box Div. --#idColor {color:gray;} </style>
This line uses important at the end. The class priority is less than the priority of the ID. IE7 is red, Firefox is blue. </div> <div class= "Important_true" > This line uses important</div> </div> <div id= "Box2" > In different browsers, the color of this line of words should be different! Ie7,firefox is red. IE6 is blue </div> </body>

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.