parent child - CSS: Adjacent sibling inside a class -
trying add top-margin adjacent sibling.
<div class="container"> <h2>header 1</h2> <p>some text , sentences...</p> <h2>header 2</h2> <p>some more text , sentences..</p> </div> normally accomplish top-margin on "header 2" using css on adjacent siblings.
p + h2{ margin-top: 12px; } however, h2 has margin defined via
.container h2{ margin: 24px 0px; } how can make adjacent siblings css work while overriding .container h2 css?
.container h2 more specific p + h2 taken consideration. need more specific selector override margin.
this should "more specific" , override:
.container p + h2 { margin-top: 12px; }
Comments
Post a Comment