Using CSS selectors, is it possible to differentiate in any way between the following two code snippets? By differentiate, I mean selecting any part (or the whole) of either snippet, but not the other.
<span role="presentation">
<span class="test" role="presentation" test-text="foo">bar</span>
</span>
and
<span role="presentation">
<span class="test" role="presentation" test-text="foo">bar</span>
baz
</span>
The web browser being used is only Firefox, so Mozilla-only features are also acceptable.
EDIT 1:
Additional details that may help answerers:
More complex versions of both of the above HTML snippets are present in the code. I've isolated it down to simplify this question, as everything else will be relevant. The only difference is the string (baz in this simplified example) in the outer span.
I'm looking for a selector that will match anything in one snippet, without matching anything in the other snippet. (I'm not sure if this is possible, so I'm trying to be maximally flexible with answers.) I can't change the upstream HTML, but I can change the CSS.
EDIT 2:
I've been asked to add more details and specifics, as this may impact the answer.
I think this will really help clarify: My goal is to hide the string bar if and only if baz is present in the upstream HTML (as shown in the second code snippet).
I'm good with hiding the entire span.test element or just the bar text string within it... either way is fine.
Regarding hiding bar, I'm open to all possibilities of hiding it so it takes up no space. I'm thinking of display: none or width: 0, but anything that results in it not taking up any space when baz is present is good.
EDIT 3:
Just a quick update: I went through the upstream code in depth, and it looks like bar will always be whitespace. I'm not sure if that opens any doors, but if it does, I thought it worth mentioning.