Page 1 of 1

removing empty paragraphs and limit <br />

Posted: Tue Oct 28, 2014 1:25 pm
by cjkeane
Hi everyone,

I need a way to remove extra paragraphs and <br /> in a textarea.

it could appear as:
<br />
<p>&nbsp;</p>
<br />
<p>&nbsp;</p>
<p>&nbsp;</p>

or

<br />
<p>&nbsp;</p>
<p>&nbsp;</p>
<br />

and i need a way to remove all extra <br /> as i have seen this posting into the db as well:

<br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br />

Re: removing empty paragraphs and limit <br />

Posted: Thu Nov 20, 2014 4:49 am
by SNivas
use margin: 0; to remove the spaces between paragraphs or empty paragraphs.

p { margin: 0; }

or

p { margin: 0 !important; }

Re: removing empty paragraphs and limit <br />

Posted: Thu Nov 20, 2014 6:34 am
by Celauran
Give your users a WYSIWYG and this sort of thing becomes inevitable. You can try to strip out the <p>&nbsp;</p> using regex or str_replace or something, but "extra" <br>, especially with a WYSIWYG, is going to be a tougher nut to crack. What problems is it causing?