2

I have perhaps quite an odd question and it seems almost to be asking too much of CSS, but if it could be done it would be quite beneficial...

I would like to, rather than using a <span> to select individual words be able to use a CSS selector to select a/some specific word(s) within an element, for example a <div> or a long <p>.

For example (I am aware that this doesn't exist[in ths particuar inflection]):

div[text~"hello"] {
     color: red;
}

This would find any iteration of the word hello in a div, and color it red.

Pseudocode select text equal to "hello" in any div set colour as red

I would like the equivalent of:

.red {
  color: red;
}
Lorem ipsum dolor sit <span class="red">hello</span> elit.

But I am looking for a CSS specific (and less bulky) way to do this.

joe_young
  • 3,991
  • 2
  • 24
  • 36

0 Answers0