Home>Article>Web Front-end> What does css important mean?

What does css important mean?

藏色散人
藏色散人 Original
2021-04-13 09:12:04 2691browse

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.

What does css important mean?

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 :

    
I am child

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!

Statement:
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
Previous article:What are css positioning Next article:What are css positioning