html - When to use element.style selector in css? -


this question has answer here:

the following list of selector types increasing specificity:

  1. universal selectors (i.e., *).
  2. type selectors (e.g., h1) , pseudo-elements (e.g., :before).
  3. class selectors (e.g., .example), attributes selectors (e.g., >>[type="radio"]) , pseudo-classes (e.g., :hover).
  4. id selectors (e.g., #example).

in addition above selectors, there default selector called,

enter image description here

when prefer using selector?

how css specificity rule applies selector?

here's specificity value

selector                          specificity         specificity in large base inline-style                      1 0 0 0             1000 id selector                       0 1 0 0              100 class,pseudo,attribute selector   0 0 1 0               10 type selector , pseudo elements 0 0 0 1                1             

copied this answer question specificity answered here.


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -