html - Apply CSS to a singly word -
is possible apply css in such way detect whenever there word in element , mark word in way? know can add <span style="...">word</span>
or <span class="...">word</span>
inline html, won't automatically detect word. there way entirely in css? appreciated.
theres no way in css. replace instances of word wrapped version , apply style per example http://jsfiddle.net/w9vbp/:
js
var word = 'hello'; var replacement = '<span class="theword">' + word + '</span>'; var re = new regexp(word, 'ig'); document.body.innerhtml = document.body.innerhtml.replace(re, replacement);
css
.theword { color:red; }
Comments
Post a Comment