I wanted to know if it's possible to style <span>
tags differently based on where it appears inside a <p>
tag.
Ex:
<p><span>Lorem</span> ipsum dolor sit amet</p>
<p>Inquit, <span>contingit</span> omnibus fidibus, ut incontentae sint.</p>
<p>Unum est sine dolore esse, alterum <span>cum voluptate.</span></p>
- If the span appears before any other text, I want to style it red,
- If the span has text before and after it, I want to style it blue,
- If the span has no text appear after it, I want to style it green.
I'm aware of ways to handle this with classes, other identifying attributes, or even JavaScript, but is there a pure CSS solution?