Forum How do I...?

Remove <br /> when starting a new page


The problem is that when there is <br /> in the html document and when it moves to the next page, you can see the <br /> as the first line of the new page.

How do we avoid this ?

Can you change the markup, and use margins instead of <br> elements? These interact better with page breaks.
The problem is that it is all user generated content. I'm not sure how to set the margins that way with user content.
So does the input look something like this:
This is a paragraph of text.<br/>
This is another paragraph of text. <br/>

And the middle <br> element is ending up by chance at the top of a new page, causing a blank line at the top of the page? If so, that's awkward, as <br> always causes a line break. The only way around it would be to process the markup, either before it is converted by Prince, or using JavaScript.
Thanks for the reply.

How do I process it ? Should I just remove all < br /> and replace with something else ?
One option could be to only replace multiple adjacent <br> elements that are separated only by whitespace and no other text characters, eg. <br/><br/>. This could be turned into an empty <div> element with a top margin, to create a gap that will disappear if it occurs at the top of a page.