What does !important mean in CSS?

后端 未结 5 1337
后悔当初
后悔当初 2020-11-21 23:32

What does !important mean in CSS?

Is it available in CSS 2? CSS 3?

Where is it supported? All modern browsers?

5条回答
  •  故里飘歌
    2020-11-22 00:22

    It is used to influence sorting in the CSS cascade when sorting by origin is done. It has nothing to do with specificity like stated here in other answers.

    Here is the priority from lowest to highest:

    1. browser styles
    2. user style sheet declarations (without !important)
    3. author style sheet declarations (without !important)
    4. !important author style sheets
    5. !important user style sheets

    After that specificity takes place for the rules still having a finger in the pie.

    References:

    • http://www.w3.org/TR/CSS2/cascade.html#cascade
    • https://russmaxdesign.github.io/maxdesign-slides/02-css/207-css-cascade.html

提交回复
热议问题