1

What is Specificity value of !important in css? Like: 100 for each ID, 10 for each attribute, class or pseudo-class, 1 for each element name or pseudo-element.

If I used !Important in css then what will be value of Specificity?

2 Answers2

2

MDN's article on specificity states about the !important rule:

When an !important rule is used on a style declaration, this declaration overrides any other declaration made in the CSS, wherever it is in the declaration list. Although, !important has nothing to do with specificity.

So, it has no specificity value. It just overrides any other rule, regardless of its value combination.

Now...

When there's more than one declaration using the !important rule, then the specificity value will be the tie breaker.

LcSalazar
  • 15,390
  • 3
  • 29
  • 62
0

Specificity value only applies with selectors. !important is considered as declaration so it means there is no specificity value to that.

More info = https://www.w3.org/TR/css-cascade-3/#biblio-css21.

In addition to that. !important discussion is also mentioned here. Relationship between !important and CSS specificity

Community
  • 1
  • 1
SimplifyJS
  • 478
  • 1
  • 5
  • 12