As I have been informed, there’s an old function in CSS:
[att^=val] – the “begins with” selector
[att$=val] – the “ends with” selector
[att*=val] – the “contains” selector
It’s supported from v2.0 of Chrome, they say, but it doesn’t work.
Is there any other way?
ADDITION:
I would like to address a HTML-tag that contains a certain text: ‘word’:
<p class="something">123 word 456</div>
A theoretical selection could be :contains():
p.something:contains('word') {}
Thanks to answers, I now know that the selector above is not for this, but then what? Is there a CSS addressing for this?
2
Answers
Code from your link that you posted is not quite ok. It have 2 mistakes.
-1- In
CSS
there is selector that is not exist insideHTML
.examples1
(typo mistake)-2- Also in
CSS
, quotes are not ok. These quotes”
need to be converted into this"
And with that fixes everything is working (of course we can not use images because of the paths, but we can test it with colors)
Direct answer: That feature is not present in CSS as of now.
But there are some ways to implement that.
Easiest would be the attribute selector but I am guessing that, that is not what you want, so what you can do is implement JS.
Now, it’ll search for all divs (or the element you provided) that contains the string and add the class.
So just add the style for the class in CSS like:
So all at once: