Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML: empty <p></p> tag show no line break

Tags:

html

css

We have a .NET application saving messages in axml. What we need to do is converting it to html. I have found a 3rd party lib "HtmlFromXamlConverter" does that, with a minor defect: If the axml contains multiple line breaks, it will be converted to something like:

<P ><SPAN STYLE="text-decoration:underline;" /> </P>
<P ><SPAN STYLE="text-decoration:underline;" /> </P>
<P ><SPAN STYLE="text-decoration:underline;" /> </P>

Which only appear as 1 line break. I cannot insert a " " as value because there is a underline style. So the question is, is there a way to config empty P tags <p></p> showing up as line breaks?

like image 609
Xi 张熹 Avatar asked Nov 27 '22 21:11

Xi 张熹


2 Answers

How about adding a tiny inline block like so:

p:after {
  content:"";
  display:inline-block;
  width:0px;
  outline:1px solid red; /* debug, remove me */
}

This will force even empty paragraphs to be of the line-height you've set.

like image 196
Mark Avatar answered Nov 29 '22 12:11

Mark


As far as I know, you can't do that with just CSS, you have to add a non-breakable space inside the paragraphs:

<p>&nbsp;</p>
like image 43
bfavaretto Avatar answered Nov 29 '22 12:11

bfavaretto