Search code examples
csscss-selectorspseudo-class

CSS pseudo content selector


I'm trying to determine the style of a div by going by what is in it. If the content is '0', it should have color: red, and if not, fall back to the usual color.

I've found there used to be :contains(value), but that doesn't exist anymore. Is there any replacement I can use for this in css?

Thanks in advance.


Solution

  • No, there isn't. If CSS was going to have a content selector, it would have kept :contains().

    For what it's worth, jQuery implements :contains(), so if you're using it already you can apply styles with it instead.