During my research for this, I stumble upon this thread, but since it is 2 years old, Im wondering if there's a recent way of targeting an element that is right before another.
For example:
<span> Element Before Div </span>
<div id="thediv"> Target Span From Here Using #thediv </div>
Is there any CSS that can accomplish this?
I'm aware of the usage of jQuery, I rather not use it if this is possible with plain CSS.
Thank you in advance.
EDIT: Example to clarify usage.
<ul>
<li>
<span>SubTitle Span</span>
<div class="subdiv">Some content after SubTitle</div>
</li>
<li>
<span>Item Description</span>
<div>Item Content</div>
</li>
<li>
<span>Item Description</span>
<div>Item Content</div>
</li>
<li>
<span>SubTitle Span</span>
<div class="subdiv">Some content after SubTitle</div>
</li>
<li>
<span>Item Description</span>
<div>Item Content</div>
</li>
<li>
<span>Item Description</span>
<div>Item Content</div>
</li>
<li>
<span>SubTitle Span</span>
<div class="subdiv">Some content after SubTitle</div>
</li>
<li>
<span>Item Description</span>
<div>Item Content</div>
</li>
</ul>
that had the previous described situation and there was 3 specific- items that would act like sub-titles for a specific group. (Like groups in select boxes) And since I had a div right after the span that had a common class all across the 3 if there as a way t target a span that came right before that specific div would save me some time. I could simply say - .divclass (target previous) span - and I would have all my span in that position with the same style. I'll edit the question with this example.
– Hélio C Apr 13 '14 at 04:51