Yes the factors you have mentioned are totally right. In this article I was abit more focused on how to calculate the weight as a number that causes a style to be applied instead of the other. Acording to the mnemonic IS-ICE, i may say the article has explained in detail on the ICE part. Towards the end, I have touched lightly on IS part:
Both rules have the same weight but the first rule will take precedence because of use of !important keyword. Otherwise, the second rule would have taken precendence.
Where I mean that the most recently applied style wins, BUT if only the previous style does not have an !important keyword.
Regarding the @layer, When you don't specify a layer in your stylesheet, the CSS processor will place your styles(those not in a layer) into an anonymous layer. Now styles in anonymous layer have a higher specificity weight than a custom layer you define on your stylesheet. A good usecase can be to put bootstrap styles in a layer you have created.
And your own styles you write not enclosed in a layer, or in a layer you have created more recently. This causes CSS processor to always apply your styles overriding what bootstrap has set.
Thanks for the mnemonic, It makes it easy to remember
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Yes the factors you have mentioned are totally right. In this article I was abit more focused on how to calculate the weight as a number that causes a style to be applied instead of the other. Acording to the mnemonic
IS-ICE, i may say the article has explained in detail on theICEpart. Towards the end, I have touched lightly onISpart:Where I mean that the most recently applied style wins, BUT if only the previous style does not have an
!importantkeyword.Regarding the
@layer, When you don't specify a layer in your stylesheet, the CSS processor will place your styles(those not in a layer) into an anonymous layer. Now styles in anonymous layer have a higher specificity weight than a custom layer you define on your stylesheet. A good usecase can be to put bootstrap styles in a layer you have created.And your own styles you write not enclosed in a layer, or in a layer you have created more recently. This causes CSS processor to always apply your styles overriding what bootstrap has set.
Thanks for the mnemonic, It makes it easy to remember