I think you are confusing the syntax of different languages.
is (the HtmlEncoded value of ASCII 10 or) the linefeed character literal in a HTML string. But the line feed character does NOT render as a line break in HTML (see notes at bottom).
\n
is the linefeed character literal (ASCII 10) in a Javascript string.
Hopefully the following illustration will make it clearer: A few points to note about Html:
is a line break in HTML. Many other elements, eg ,
T.innerText = "Position of LF: " + t.value.indexOf("\n");
p1.innerHTML = t.value;
p2.innerHTML = t.value.replace("\n", "
");
p3.innerText = t.value.replace("\n", "
");
innerHTML
value of the TEXTAREA
element does not render Html. Try the following: to see.
P
element renders all contiguous white spaces (including new lines) as one space.TEXTAREA
renders LF as a new line inside the text area box.