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
  • 4,107
  • 2
  • 27
  • 38
  • Here are the available pseudo elements, as you can see there currently isn't anything that does what you are looking for http://www.w3.org/TR/CSS21/selector.html#pseudo-elements – Joe Sager Dec 23 '14 at 19:22

0 Answers0