In case an element is absent from the DOM, I want to include margin space. Conversely, if the element is present, no margin space should be added. I have experimented with CSS for this purpose:
A - To ensure there is no margin-top if the H2 title is displayed on the page:
#content > article > h2 > div > p:nth-child(1) {
margin-top: 0;
}
B - To add margin-top if the H2 title is not present:
#content > article > div p:nth-child(1) {
margin-top: 32px;
}
I am looking for a way to prioritize the CSS configurations so that one can override the other based on whether the H2 is missing or not.
Thank you,