CSS selector for elements without text siblings

I am trying to find a CSS selector that can help me distinguish between <var> tags in these two different usage modes:

 <p><var>Foo</var></p> 

and

 <p>Some text <var>Foo</var> and more text</p> 

Basically, if var has a sibling that is the text node, I need it differently in a different way. Suggestions?

+1
css css-selectors
source share
1 answer

This is not possible, sorry. See that discussion: http://forum.userstyles.org/comments.php?DiscussionID=6 or the official W3C pages http://www.w3.org/TR/css3-selectors/ , where you can see that even CSS3 does not support this. The only way CSS even considers DOM text nodes is: an empty pseudo-class that selects elements that are empty, i.e. They have no children or text nodes.

+1
source share

All Articles