Home > Web Front-end > HTML Tutorial > The usage of !important in CSS and its performance under IE6_html/css_WEB-ITnose

The usage of !important in CSS and its performance under IE6_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:41:31
Original
1286 people have browsed it

!important usage and performance under IE6:
!important can increase the priority of the specified CSS statement. To use it, add !important after the corresponding CSS statement. For example:

<!DOCTYPE html>   <html>   <head>   <meta charset=" utf-8">   <meta name="author" content="http://www.51texiao.cn/" /><title>蚂蚁部落</title><style type="text/css">.mytest{  color:blue!important;  color:red;}</style></head><body>  <div class="mytest">蚂蚁部落</div></body></html>
Copy after login

Everyone knows that CSS styles have the "proximity principle", that is, styles defined later can override previous styles. If !important is not used in the above code, then The font color appears red.
Currently all mainstream browsers support !important, but it is not fully supported on IE6. Why is it said that it is not fully supported? Because it is supported in some cases and not supported in some cases. For example, in the above code, IE6 browser Not supported, the text will be rendered in red font. Let’s look at the following example:

<!DOCTYPE html>   <html>   <head>   <meta charset=" utf-8">   <meta name="author" content="http://www.51texiao.cn/" /><title>蚂蚁部落</title><style type="text/css">.mytest{  color:blue!important;}.mytest{  color:red;}</style></head><body><div class="mytest">蚂蚁部落</div></body></html>
Copy after login

In the above code, you can see that the font color is displayed in blue, which means that if If the two pieces of code are used in the same curly bracket ({}), it will not work under IE6. If they are used separately in two curly brackets ({}), it will work.

The original address is: http://www.51texiao.cn/div_cssjiaocheng/2015/0501/500.html

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template