Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    JAG
    JAG is offline
    New Coder
    Join Date
    Feb 2011
    Posts
    63
    Thanks
    24
    Thanked 0 Times in 0 Posts

    Arrow CSS Selector: Target Sibling Before

    Guys, I have a layout like this:

    <p></p>
    <p></p>
    <div></div>
    <p></p>
    <p></p>

    I want to target, using CSS, only the first <p> BEFORE <div>. I know that if I wanted to target the first <p> after <div> I would go: div + p {}, but how can I target only the first <p> prior to <div> without using classes or IDs? Please, no jQuery suggestions.
    Last edited by JAG; 02-13-2014 at 12:40 AM. Reason: resolved

  • #2
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,666
    Thanks
    6
    Thanked 1,006 Times in 979 Posts
    This is not possible in CSS. As a cascade can only go downwards, CSS can only address successive elements and/or children.

  • Users who have thanked VIPStephan for this post:

    JAG (02-13-2014)

  • #3
    JAG
    JAG is offline
    New Coder
    Join Date
    Feb 2011
    Posts
    63
    Thanks
    24
    Thanked 0 Times in 0 Posts
    Makes sense. Guess I'll have to look for a jQuery solution. Thanks Stephan.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •