output:
hello How are you
code:
<p>hello <br> How are you </p> How to achieve same output without <br>?
word-wrap: break-word; is the current one. white-space: pre-wrap; is instead for something different! It preserves all whitespaces and linebreaks are ONLY done at \n (a linebreak in the source), <br> and as necessary to fill line boxes.
Try \n just after from where you want to break the line.
In HTML, the <br> tag is used for line break. It is an empty tag i.e. no need to add an end tag. Writing <br> tag is perfectly fine.
You can use white-space: pre; to make elements act like <pre>, which preserves newlines. Example:
p { white-space: pre; } <p>hello How are you</p> Note for IE that this only works in IE8+.
Impossible with the same HTML structure, you must have something to distinguish between Hello and How are you.
I suggest using spans that you will then display as blocks (just like a <div> actually).
p span { display: block; } <p><span>hello</span><span>How are you</span></p> If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With