Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing empty paragraph tags

Tags:

c#

css

vb.net

I would like to find the simplest way to trim the empty

tags before any text starts. for example i have the below text.
<p> </p><p> </p>
<p> </p><p>     </p>
<p>    </p>
<p>This is an example<br></p><p> </p><p>continue </p>

I would like the output to be <p>This is an example<br></p><p> </p><p>continue </p>

I want all the empty P tags to be removed. There can be more than one space between

tags.

I have the options to use CSS or VB or c#.

like image 527
Rad Avatar asked Apr 21 '26 20:04

Rad


1 Answers

You have tagged your question in css. So, I'm providing you an answer in css using :empty pseudo class selector:

p:empty{
  display: none;
}

See can I use :empty


As per your updated question:

you can use not like below:

p:empty :not(p + p:empty){
   display: none;
}
like image 175
Bhojendra Rauniyar Avatar answered Apr 24 '26 12:04

Bhojendra Rauniyar