Idle picking CSS noticed a strange moment.

The body style specified with !important ignored by the browser and the style specified in the usual way is determined. As far as I know, inherited properties with this instruction have the highest priority of inheritance, not counting <style> .

Are there any exceptions or did I miss something?

Screen1 Screen2

  • Make your code executable. Something tells me that you have a banal ochepyatka in the code. - Vadizar
  • Here I did . Actually the title inherits, the paragraph - no. - Alex
  • Forgot to specify the style for the paragraph, now both do not inherit. Why so? - Alex
  • style for the title * - Alex

1 answer 1

Using !important you increase the priority of the current selector. At the same time, the importer does not affect the style inheritance rules for the child elements.

For example, if you have a page somewhere above your code style:

 body#dumbid{color: orange;} 

And you cannot change it in any way or somehow change the markup to get rid of it, in such a last resort you can use !important to override it, or duplicate the selector to equalize the priority.

 body{color: blue !important;} 

So you only neutralized the body#dumbid , but did not change the inheritance rules for the child elements.

In your case, it does not matter if there is an !important or not body style. The p selector will take precedence since it is more specific.