0

With CSS3 is it possible to target a previous element?

So if i had this mark up:

<p>Target Me </p>
<p id="second">Second</p>

Something like this would make the text 'Target Me' bold:

#id -previous {
   font-weight: bold;
}
Evanss
  • 23,390
  • 94
  • 282
  • 505

1 Answers1

1

One solution is to do it with jQuery. It would look something like

$("#second").prev().css('font-weight', 'bold');
Gustav
  • 1,361
  • 1
  • 12
  • 24
  • I will if needs be but I was hoping for a CSS3 solution. Thanks – Evanss Apr 26 '12 at 13:37
  • 1
    http://stackoverflow.com/questions/1817792/css-previous-sibling-selector possible duplicate... And as the praised guy says, "No, there is no "previous sibling" selector." – Gustav Apr 26 '12 at 13:44