0

We're trying to control vertical spacing on content and have everything working great except when content follows a div - consider the following:

<div>
  <ul>
    <li></li>
  </ul>
</div>

We'd like to remove top margin from all ul's that immediately follow a div so have been trying:

div + ul {
  margin-top: 0;
}

Is this the proper use for this selector?

We just can't seem to get it working - any pointers in the right direction would be much appreciated.

Cheers

Ben

CMSCSS
  • 2,076
  • 9
  • 28
  • 49

1 Answers1

2

It has the word "adjacent" in it, this means "next to": your ul is not "next to" your div (on the same hierarchical level) but inside it.

What you want is a direct (not recursive) child selector, > so:

div > ul { ... }

And if it only happens to the first child of that div:

div > ul:first-child { ... }
Ming
  • 4,468
  • 1
  • 21
  • 21