Hi, Daniel,
the best I can come up with is to target the last child in the following markup.

div.section p:last-child {}

<div class="section">
        <h2>Header</h2>
        <p>First paragraph</p>
        <p>Last paragraph</p>
</div>
<div class="section">
        <h2>Another header</h2>
</div>

I suggest you to have a look on browser compatibility tables:
http://www.quirksmode.org/css/contents.html#t35

The last-child selector is not supported until IE 9. Therefore I would
simply use the following:

p.last-child {}

<h2>Header</h2>
<p>First paragraph</p>
<p class="last-child">Last paragraph</p>
--
>{U}(")>        Čimo

Michal Čizmazia


On Fri, Oct 1, 2010 at 11:29, Daniel Baars <i...@danielbaars.nl> wrote:
>
> Hello,
>
> Is there a way in CSS to match a first element which is the PREVIOUS
> sibling to the second element?
>
> Example: I want to target the paragraph before every header.
>
> <h2>Header</h2>
> <p>First paragraph</p>
> <p>Last paragraph</p> <!-- I want to style this paragraph -->
> <h2>Another header</h2>
>
> After quite a bit of Google-ing it doesn't seem possible but I don't
> understand why. Is this a scenario that I should solve in a more
> intelligent way than I have been able to think of so far?
>
> Cheers,
>
>
> Daniel
>
______________________________________________________________________
css-discuss [cs...@lists.css-discuss.org]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
List policies -- http://css-discuss.org/policies.html
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/

Reply via email to