tags:

views:

64

answers:

3

Due to mod rights on a site, I can only add css (no js etc...). When users input text in a comment box, it saves it and then displays it as a <p>. is there any way through css i can search for a specific word in the <p> tag and remove/censor it?

Thanks

+4  A: 

There is no practical solution for that ( You may be able to select elements based on the value and hide them in CSS3 but it wouldn't be cross-browser friendly, if at all possible ). I'm afraid you'll have to use JS/server-side for a real solution.

On the hacky side of things and for IE only, you may be able to use an expression and display:none elements which contain certain strings in their nodeValue, it wouldn't work for modern browsers.

meder
A: 

If parent element in this case input field has class or id you can hide elements inside like this
textarea#mytextarea p{
display:none;
}

Gil Duzanski
This is along the lines of what I was attempting, however there doesn't seem to be a way to search for a particular word!
Philkav
A: 
  • Once upon a time, there was a pseudo-class :contains() in the wonderful spec of CSS3 selectors ... but it disappeared early and afaik well before any implementation.

  • A JS solution has one problem: search bots and any user without JS (or displaying the source code) will see the f***ing original text :)

Felipe Alsacreations