-1

Possible Duplicate:
CSS previous sibling selector

In a list, if there are 3 list items:

1 <li>..</li>
2 <li>..</li>
3 <li>..</li>

It is possible to use, for example li+li to get the one after the targeted list item.

My question: How to get the one BEFORE the targeted item?

Community
  • 1
  • 1
Phil
  • 13,875
  • 21
  • 81
  • 126

1 Answers1

1

li ~ li

EDIT: Oh, now that I think of it, what you want is not supported in CSS3, but hopefully will get into CSS4 with the feature called subject selector. It is the $ sign, and indicates which rule will be the selector's subject. I recently also needed it to select parents of a given match (formerly proposed as :parent selector).

An example would be $li + li. Unfortunately there is no support yet and no known schedule.

P Varga
  • 19,174
  • 12
  • 70
  • 108
  • I have read that page and tried it all extensively before asking. That one works for all the ones coming after as well, unlike + which only applies for 1 coming after. Thank you though. – Phil Feb 20 '12 at 02:13
  • Oh, okay, misunderstood the question, updated answer. – P Varga Feb 20 '12 at 03:22
  • I agree with @PéterVarga as I don't think this will be possible via CSS until CSS4 selectors are implemented. – Jim Jeffers Feb 20 '12 at 04:05
  • 2
    The subject selector is no longer `$` as of January 2012. – BoltClock Feb 20 '12 at 14:00