In my website I have a particular word which appears on many of my pages and want every single one to be stylised to be bold. Is there a way to do this via CSS or will I have to add code to every single page?
Asked
Active
Viewed 80 times
-1
-
Could you use JavaScript? or just CSS? – Adam Dec 12 '16 at 22:02
-
no way to tell really; no code and which element tag are you using for it and if there's an id/class assigned to it – Funk Forty Niner Dec 12 '16 at 22:02
-
There is no id/class assigned to the word itself, but there are a few id/class tags that encompass that specific word across the website – Gareth Evans Dec 12 '16 at 22:04
-
Here you go: http://stackoverflow.com/questions/1230445/javascript-regex-how-to-bold-specific-words-with-regex – AndrewL64 Dec 12 '16 at 22:07
-
`` `.shared-class{ font-weight: bold;}` As easy as that... – GROVER. Dec 12 '16 at 22:08
-
But that would bold out everything within the class, whereas I just want ONE word within the class to be bold... :/ @badjuju – Gareth Evans Dec 12 '16 at 22:09
1 Answers
2
I don't think there is a way to do this with CSS, without adding markup to every occurrence of the word.
You can use a combination of CSS/JQuery to do it like this:
CSS:
.word {
font-weight: bold;
}
JS:
$('html').text().replace(/word/g,"<span class='word'>$1</span>");

Adam
- 2,214
- 1
- 15
- 26