[css4-selectors] Proposal: Previous sibling combinator

Hello

In my everyday work I often miss a Previous sibling selector. The usual 
use case is a list following a paragraph, which actually is a caption of 
introduction to the list:

<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; }

I am aware of the fact that there are workarounds for this use case, but 
they are not too satisfactory:
- Apply a bottom margin of 0 to the p element: This will have 
consequences on the styling of other elements, that will all need a top 
margin when following a p element.
- Apply a class to the p element that precedes the ul: Markup-based 
workarounds have the downside that they cause extra work e.g. when 
setting up a CMS. I need to implement the class in the online text 
editor, and teach the admins to use it on the p when an ul follows. I am 
generally convinced that a markup-independent solution would be 
appropriate for this kind of use case.

Best Regards
Markus Ernst

Received on Monday, 11 February 2013 11:22:42 UTC