Re: [css4-selectors] Proposal: Previous sibling combinator

On Mon, 11 Feb 2013 12:22:12 +0100, Markus Ernst <derernst@gmx.ch> wrote:


> <p>My favorite fruits:</p>
> <ul>
>    <li>Pear</li>
>    <li>Banana</li>
> </ul>
>
> It is most often convenient to style the p element with a top and bottom  
> margin, but you want the ul to follow immediately. It would be very cool  
> to have a Previous sibling selector in this case (I use the minus sign  
> for the example, which is possibly not the best choice):
>
> p { margin: 0.7em 0; }
> p - ul { margin-bottom: 0; }

The current draft already proposes a mechanism for doing this kind of  
stuff:

!p + ul { margin-bottom: 0; }

http://www.w3.org/TR/selectors4/#subject
http://dev.w3.org/csswg/selectors4/#subject

-- 
Øyvind Stenhaug
Opera Software ASA

Received on Monday, 11 February 2013 11:59:26 UTC