Reputation: 6905
An HTML text area works fine with new lines ("\n") when they're after any other content in the text area, whether it be whitespace characters like spaces or tabs ("\t") or not.
However, when text area content begins with a new line (for example, "\ntest"), that new line gets cut off on display.
Any ideas on what causes this/how to remedy it?
Upvotes: 0
Views: 288
Reputation: 24396
This seems to be by the spec.
A single newline may be placed immediately after the start tag of
pre
andtextarea
elements. If the element's contents are intended to start with a newline, two consecutive newlines thus need to be included by the author.
Note that in the past there were some bugs in the various browsers regarding leading new lines in elements:
Upvotes: 1