Skip to content Skip to sidebar Skip to footer

Html Newline Using Fromcharcode Is Not Working

I am using String.fromCharCode to add new line (or) carriage return to my html text. It is like, 'Ant the other line here...' + String.fromCharCode(13) Jsfiddle is @http://jsfiddl

Solution 1:

If you want a line break in HTML you need to supply <br> entity instead of a line break (your String.fromCharCode(13) code) since HTML interprets line breaks as usual spaces in text.

Solution 2:

The reason that a newline character is not forcing a new line, is that in HTML a newline character doesnt do anything and is ignored.

In order to force text onto a new line, you will need to add the appropriate HTML tag, such as <BR> or put your text inside paragraphs <p>.

See the updated fiddle.

Solution 3:

String.fromCharCode(10);

with CSS

white-space: pre-line;

Here si working example: https://jsfiddle.net/Nxja/3xtcqdej/1/

Post a Comment for "Html Newline Using Fromcharcode Is Not Working"