Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the function of important in css?

2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you css! what is the role of important, I believe most people do not understand, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

The role of important in CSS

By adding {* rulecodes}, you can write hack to IE6.0,IE7.0 and FireFox.

* all IE browsers can recognize it, but Firefox browsers cannot.

! Important can only be recognized by IE7.0 and Firefox, but IE6.0 cannot be successfully applied.

The difference

(1) the hack that distinguishes ie from firefox is: border:2pxsolid#f00;*border:1pxsolid#f00

(2) the hack that distinguishes Ie6.0 from Ie7.0 and firefox is as follows: borderler1pxsolidfolf00importantlyborderly2pxsolidfolf00

Parsing

In (1), the reason for putting * behind is that the firefox does not recognize *, which results in setting the border; on it only once, but after the ie series has made two border settings, the latter attribute overrides the previous attribute, so it is an one-pixel border.

In (2), the reason why! important is placed in the first border setting is because it increases the priority of this border, even if setting border once or even N times is invalid, but Ie6.0 does not accept this rule, which causes it to apply the second border setting, that is, the second override the principle of the first time, not that it does not recognize! important;, so its border is a 2-pixel red box.

Exampl

CSS

# Box {colorRedless important; color:blue;}

HTML

The color of this line should be different in different browsers!

This example should be the common use of important. In IE, this line is blue, and in firefox, it is red.

The above is all the contents of this article "what is the role of important in css?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report