CSS selector based on element text?

Harry picture Harry · Mar 26, 2011 · Viewed 391.4k times · Source

Is there a way to select an element in css based on element text?

ie:

li[text=*foo]

<li>foo</li>
<li>bar</li>

That probably doesn't work.

Edit: Also only need to support Chrome.

Answer

Błażej Klisz picture Błażej Klisz · Mar 26, 2011

I know it's not exactly what you are looking for, but maybe it'll help you.

You can try use a jQuery selector :contains(), add a class and then do a normal style for a class.