I want to change a specific word's css through out the site.I can't add any html element around that word (like span,div) because that word is using several times and many places on site.
Is it possible to change this by css?
I want to change a specific word's css through out the site.I can't add any html element around that word (like span,div) because that word is using several times and many places on site.
Is it possible to change this by css?
You can't do this purely with CSS. So your options are:
What you said you "couldn't" do — edit the source files, e.g., global search and replace. Put a span with a relevant class around the word and style that class.
Use JavaScript to retroactively wrap the word in an element (a span
would probably be best), again use a class on it and style that class.
If you use jQuery, this answer helps you easily wrap specific words with a span. If you don't, this other answer shows how to do it.
I'm a fraid a pure CSS solution will not work for you. I can only offer a JavaScript solution that will wrap the target words in a tag for you.
var styleWord = function(target, word)
{
var html = target.innerHTML;
html = html.replace(new RegExp(word, "g"), '<span class="styled">'+word+'</span>');
target.innerHTML = html;
};
The function I wrote takes in two params: the target element wherein you want the words changed (it won't leave HTML tags and attributes alone, so you might want to refine it) and the word you're looking for. It will wrap the word in a span
so you can style it any way you wish.