Edit: oh, I get it. You want the entire <p> tag to be red when the span starts part way through. Why not put a class on the <p>? It seems crazy counterintuitive to select elements backwards like that.
Yes in trivial cases you might put a class on the P element. But what about when you have dynamic updates to the DOM? If I have 15 P elements in a collection and not all have content (think of a discussion thread and comments) - how would I specify which P elements to style vs. those I don't want styled?
The ability to style based on content of the selector is powerful in this case.
Comments
Wait, what am I missing?
<p><span class="fast">Red text</span></p>
with
p span.fast { color: red; }
will work just fine.
Edit: oh, I get it. You want the entire <p> tag to be red when the span starts part way through. Why not put a class on the <p>? It seems crazy counterintuitive to select elements backwards like that.
Yes in trivial cases you might put a class on the P element. But what about when you have dynamic updates to the DOM? If I have 15 P elements in a collection and not all have content (think of a discussion thread and comments) - how would I specify which P elements to style vs. those I don't want styled?
The ability to style based on content of the selector is powerful in this case.