Css inheritance



  • The question is: Why not? div>p Isn't it red? id The priority is higher than the attribute. Or p not inherited parameters divalthough font-weight inherited.

    I'd be happy if we had an article.

    p{
      color: gold;
    }
    #p{
      font-weight: bold;
      color: red;
    }
    <!DOCTYPE html>
    <html lang="en">
    <head>
      <meta charset="UTF-8" />
      <title>Document</title>
    </head>
    <body>
      <p>Lorem ipsum dolor sit amet.</p>
      <div id="p">
      <p>Lorem ipsum dolor.</p>
      <p>Temporibus, voluptate, praesentium.</p>
      <p>Itaque, quo nihil.</p>
      <p>Repudiandae, consequatur, rem?</p>
      </div>
    </body>
    </html>



  • You're right that id higher than the Tag itself. But priority is higher with respect to the teg to which idi.e. <div>♪ With regard to <p>so he has a more appropriate selter, the one with the same tag.

    In other words, <p> inherited the parameters <div id="p">but they were redefined.

    I'm not recommending, but recommending:

    McFairland David - Big CSS3. Three. - SPB: Peter, 2014 - 608 s: Il. - (Seria of Westellers O’Reilly). ISBN 978-5-496-00428-2.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2