1

I'm using html & css. I want a certain word to always be set to the colour red. I can use the span tags to set one word to red, but I don't want to have to type this out for every occurance of the word, is there kind of like a "global" way of doing this?

Thanks.

Lets say the word is "cat" btw.

user1364363
  • 49
  • 1
  • 4

2 Answers2

1

You can't. CSS styles elements, not arbitrary bits of text.

You could programatically modify the document (either server side or with client side JS) to add additional markup (e.g. <span class="cat"> and </span>) around the words you care about (being careful to only alter words in regular text nodes and not in CDATA sections or attribute values.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
0

I think you need to do this either manually or with Javascript using regular expressions. A good jQuery plugin is http://johannburkard.de/blog/programming/javascript/highlight-javascript-text-higlighting-jquery-plugin.html

Johannes Klauß
  • 10,676
  • 16
  • 68
  • 122