Is it possible to target <p>&nbsp;</p> with just CSS?

Issue

I know I can remove p tags only with &nbsp; being in them with JS/jQuery like so:

$("p").filter(function(){
    return $.trim(this.innerHTML) === "&nbsp;"
}).remove();

But is it possible to target these with just CSS. Something like these doesn’t work:

p[&nbsp;] { display: none; }
p:contains('&nbsp;') { display: none; }

Solution

Unfortunately this isn’t possible with just CSS. :contains used to be part of the CSS3 spec but has now been removed.

Answered By – kmoe

Answer Checked By – Jay B. (AngularFixing Admin)

Leave a Reply

Your email address will not be published.