Evanss
Evanss

Reputation: 23563

CSS3 target previous element?

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

Upvotes: 0

Views: 216

Answers (1)

Gustav
Gustav

Reputation: 1341

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

$("#second").prev().css('font-weight', 'bold');

Upvotes: 1

Related Questions