-3

The following list of selector types is by increasing specificity:

  1. Universal selectors (i.e., *).
  2. Type selectors (e.g., h1) and pseudo-elements (e.g., :before).
  3. Class selectors (e.g., .example), attributes selectors (e.g., >>[type="radio"]) and pseudo-classes (e.g., :hover).
  4. ID selectors (e.g., #example).

In addition to above selectors, there is a default selector called,

enter image description here

When do we prefer using this selector?

How the CSS specificity rule applies to this selector?

BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
overexchange
  • 15,768
  • 30
  • 152
  • 347
  • 5
    That's not a selector. That's a typical browser developer tool's (rather confusing) representation of an element's inline `style` attribute. – BoltClock Sep 21 '15 at 08:28
  • element.style can not be written in css file but its the css that is inline to particular html element. Inline css is used to override the css that are applied to the element using the stylesheets. – razorranjan Sep 21 '15 at 08:29
  • If you supply quotes and screenshots, it helps if you tell us what source they are from. – Jeroen Sep 21 '15 at 08:30

1 Answers1

1

Here's the 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 and pseudo elements 0 0 0 1                1            

Copied from this answer but this question is specifically for specificity so answered here.

Community
  • 1
  • 1
Bhojendra Rauniyar
  • 83,432
  • 35
  • 168
  • 231