1

Say I have an h4

h4 {
  margin-bottom: 25px;
}

// somehow select h4's that are immediately followed by p tags
h4 + p {
  margin-bottom: 10px;
}

My hope was to change the bottom margin if a paragraph tag followed it rather then any other tag.

Is there any efficient way to do this with css or scss?

If not I plan to just rewrite the typography using top margin except for the first element. I would like to avoid the rewrite if possible.

Andrew
  • 189
  • 1
  • 7
  • 1
    Read about the `has` selector, but sadly there's no support for it yet https://developer.mozilla.org/en-US/docs/Web/CSS/:has For your example would have been `h4:has(+ p) {}` – fernandopasik Feb 06 '20 at 00:15

0 Answers0