h3 + ul { margin-top: 0; }
This targets ul, is it possible to target h3 instead?
Instead of selecting all uls that appear after a h3, I want to select all h3s that precede a ul
h3 + ul { margin-top: 0; }
This targets ul, is it possible to target h3 instead?
Instead of selecting all uls that appear after a h3, I want to select all h3s that precede a ul
There is no selector that does what you're looking for*.
The "Selectors Level 4" specification is currently in draft phase and is not implemented by any browser that I know of at the time of writing. It introduces the concept of a selector "subject", which would allow you to specify the part of the selector that the styles are applied to:
/* applies to ul */
h3 + ul {
margin-top: 0;
}
/* applies to h3 */
!h3 + ul {
margin-top: 0;
}
* yet