Home >Web Front-end >Front-end Q&A >What does css important mean?
important in css is a syntax used to increase the application priority of specified style rules. Its syntax format is such as "{sRule!important}"; high-priority css styles will override low-priority css styles. style.
The operating environment of this article: Windows7 system, HTML5&&CSS3 version, Dell G3 computer.
In HTML web pages, css styles are used based on priority. CSS styles with high priority will override styles with low priority, and many css attributes are inherited, which will affect us. Web page display, we can use !important to change this situation.
!important is a syntax defined in CSS1, which is used to increase the application priority of specified style rules. The syntax format { sRule!important } is written directly at the end of the definition, such as:
p{color:green !important;}
Note: IE has never supported this syntax, but other browsers do. Therefore, we can use this to define styles for FF and IE browsers respectively.
If a style A is defined, such as font-size, and you do not intend to let the style A overwrite this font-size in the future, you can also use !important. And if the new style is also used! important will still be forcibly overwritten
.A{ font-size:12px !important; } .A{ font-size:14px; //不会生效 } .A{ font-size:14px !important; //生效 }
Note that it must be a style with the same name, that is, a style with both style names called A. It will not work if it is a parent and a child, for example :
<html> <head> <style> .father{ font-size:12px !important; } .child{ font-size:14px; } </style> <body> <div class="father"> <div class="child">I am child </div> </div> </body> </html>
In this case, the child's font-size is 14px and is not affected by the father.
【Recommended learning: css video tutorial】
The above is the detailed content of What does css important mean?. For more information, please follow other related articles on the PHP Chinese website!