What is syntax for selector in CSS for next element?
The >
is a child selector. So if your HTML looks like this:
<h1 class="hc-reform">
title
<p>stuff here</p>
</h1>
... then that's your ticket.
But if your HTML looks like this:
<h1 class="hc-reform">
title
</h1>
<p>stuff here</p>
Then you want the adjacent selector:
h1.hc-reform + p{
clear:both;
}
You can use the sibling selector ~
:
h1.hc-reform ~ p{
clear:both;
}
This selects all the p
elements that come after .hc-reform
, not just the first one.
no >
is a child selector.
the one you want is +
so try h1.hc-reform + p
browser support isn't great
This is called the adjacent sibling selector, and it is represented by a plus sign...
h1.hc-reform + p {
clear:both;
}
Note: this is not supported in IE6 or older.