The HTTP and MIME specs specify that header lines must end with \r\n, but they aren't clear (some would argue that it isn't clear if they are clear) about what to do with the contents of a TEXTAREA. (See, for instance, this thread from an HTML working group about the issue.)

Here's a quote from the HTTP/1.1 spec about message headers:

The line terminator for message-header fields is the sequence CRLF. However, we recommend that applications, when parsing such headers, recognize a single LF as a line terminator and ignore the leading CR.

I think that is a good strategy in general: be strict about what you produce but liberal in what you accept. You should assume that you will receive all sorts of line terminators. (Note that in addition to CRLF and LF, Mac OS-9 used CR alone, and there are still a few of those around. The Unicode standard (section 5.8) specifies a wide range of character sequences that should be recognized as line terminators; there's a list of them here.)

Answer from Ted Hopp on Stack Overflow
Top answer
1 of 2
55

The HTTP and MIME specs specify that header lines must end with \r\n, but they aren't clear (some would argue that it isn't clear if they are clear) about what to do with the contents of a TEXTAREA. (See, for instance, this thread from an HTML working group about the issue.)

Here's a quote from the HTTP/1.1 spec about message headers:

The line terminator for message-header fields is the sequence CRLF. However, we recommend that applications, when parsing such headers, recognize a single LF as a line terminator and ignore the leading CR.

I think that is a good strategy in general: be strict about what you produce but liberal in what you accept. You should assume that you will receive all sorts of line terminators. (Note that in addition to CRLF and LF, Mac OS-9 used CR alone, and there are still a few of those around. The Unicode standard (section 5.8) specifies a wide range of character sequences that should be recognized as line terminators; there's a list of them here.)

2 of 2
31

what do browsers send up for a <textarea></textarea> if it has multiple lines?

All modern browsers send CRLF (\r\n). However this is not something that has been satisfactorily standardised so I would definitely consider it worthwhile to normalise the newlines of all multi-line input text.

When the value is read through JavaScript rather than being submitted directly from a form, browser behaviour differs. IE and Opera return strings with CRLFs in; Firefox and WebKit return LF. So any form that gets submitted with JavaScript/XMLHttpRequest help is likely to come in either form.

🌐
WebDeveloper.com
webdeveloper.com › community › 16114-what-does-quotrquot-quotnquot-mean
What does "/r" "/n" mean ???:(
It is like this String toHTML(String value) { if ( value == null ) return ""; value = replace(value, "rn","<BR>&nbsp;&nbsp;&nbsp;&nbsp;"); value = replace(value, "r","<BR>&nbsp;&nbsp;"); value = replace(value, "n","<BR>&nbsp;&nbsp;"); return value; } String toHTMLother(String value) { if ( value == null ) return ""; value = replace(value,"<BR>&nbsp;&nbsp;&nbsp;&nbsp;", "rn"); value = replace(value, "<BR>&nbsp;&nbsp;","r"); value = replace(value,"<BR>&nbsp;&nbsp;", "n"); return value; } My question is why they use such a transfer function instead of putting the data directly into the database? And how can "<BR>&nbsp;&nbsp;" take the place of "/r" reply? 0 · Copy linkTweet thisAlerts: @pyroAug 26.2003 — # in HTML, <br> is the line break.
🌐
CKEditor
ckeditor.com › old › forums › Support › Problem-rn-and-rn-HTML-input
Problem with "rn" and "\r\n" with HTML input | CKEditor.com Forums
It has nothing to do with the editor. You either are calling mysql_real_escape_string more than once or use its output without sending it to the database. For example, if you call cleaninput and then cleanedit, you'll end up with rn sequences instead of new lines.
🌐
W3Schools
w3schools.com › jsref › jsref_regexp_carriagereturn.asp
RegExp \r Metacharacter
Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, Python, PHP, Bootstrap, Java, XML and more.
🌐
GeeksforGeeks
geeksforgeeks.org › php › whats-the-difference-between-n-and-rn-in-php
What's the difference between \n and \r\n in PHP ? - GeeksforGeeks
July 23, 2025 - This line break is not visible on the browser. In order to visualize these on the browser, the nl2br() method can be used in PHP. However, \n can also be used in Windows systems. \r\n is the standard line-termination for text formats on the Internet.
Top answer
1 of 5
73

\r is "Carriage Return" (CR, ASCII character 13), \n is "Line Feed" (LF, ASCII character 10). Back in the days, you had two ASCII characters at the end of each line to tell a printer what to do - CR would tell the printer to go back to the left edge of the paper, LF would advance to the next line.

Operating systems still have different conventions as to what the end of a line looks like -- some of them have \n\r, some have \n, some have \r\n.

In Javascript, you mostly deal with \n - this is how strings are typically switching to the next line. However, depending on what strings you are working with, you may be encountering \r as well.

2 of 5
26

Normally \r represents a carriage return character (ASCII 0x0d), and \n is a newline character (ASCII 0x0a). This page has a list of all the special characters, quoted here for completeness:

  • \f matches form-feed.
  • \r matches carriage return.
  • \n matches linefeed.
  • \t matches horizontal tab.
  • \v matches vertical tab.
  • \0 matches NUL character.
  • [\b] matches backspace.
  • \s matches whitespace (short for [\f\n\r\t\v\u00A0\u2028\u2029]).
  • \S matches anything but a whitespace (short for [^\f\n\r\t\v\u00A0\u2028\u2029]).
  • \w matches any alphanumerical character (word characters) including underscore (short for [a-zA-Z0-9_]).
  • \W matches any non-word characters (short for [^a-zA-Z0-9_]).
  • \d matches any digit (short for [0-9]).
  • \D matches any non-digit (short for [^0-9]).
  • \b matches a word boundary (the position between a word and a space).
  • \B matches a non-word boundary (short for [^\b]).
  • \cX matches a control character. E.g: \cm matches control-M.
  • \xhh matches the character with two characters of hexadecimal code hh.
  • \uhhhh matches the Unicode character with four characters of hexadecimal code hhhh.
Find elsewhere
🌐
PHP
php.net › manual › en › function.nl2br.php
PHP: nl2br - Manual
* * @param string The string to convert * @param string The string to use as line separator * @return string The converted string */ function br2nl ( $string, $separator = PHP_EOL ) { $separator = in_array($separator, array("\n", "\r", "\r\n", "\n\r", chr(30), chr(155), PHP_EOL)) ? $separator : PHP_EOL; // Checks if provided $separator is valid. return preg_replace('/\<br(\s*)?\/?\>/i', $separator, $string); } ?> ... Seeing all these suggestions on a br2nl function, I can also see that neither would work with a sloppy written html line break..
🌐
Cyber Definitions
cyberdefinitions.com › definitions › RN.html
RN | What Does RN Mean?
March 21, 2022 - In a text, RN means 'Right Now,' 'Registered Nurse,' and 'Royal Navy.' This page explains how RN is used in texting or on apps like TikTok or Instagram.
🌐
Sololearn
sololearn.com › en › Discuss › 467890 › what-is-the-difference-between-the-r-and-n
What is the difference between the \r and \n? | Sololearn: Learn to code for FREE!
As visph said, the end of line ... 10), while in Windows the end of line consists of two characters: "\r\n" (ASCII code 13, followed by ASCII code 10)....
🌐
Attacomsian
attacomsian.com › blog › java-replace-newline-character-with-html-line-break
Replace new line (\n) with HTML br tag in string using Java
July 24, 2021 - String address = "ACME Inc.\n" + "2683 Jerry Toth Drive\n" + "New York NY 10010\n" + "United States"; // Replace new line with <br> String html = address.replaceAll("(\r\n|\n)", "<br>"); // Print HTML string System.out.println(html);
🌐
W3Schools
w3schools.com › jsref › jsref_regexp_newline.asp
RegExp \n Metacharacter
W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.
🌐
npm
npmjs.com › package › react-native-render-html
react-native-render-html - npm
An iOS/Android pure javascript react-native component that renders your HTML into 100% native views.
      » npm install react-native-render-html
    
Published   Jan 24, 2022
Version   6.3.4
Author   Meliorence
🌐
Acronym Finder
acronymfinder.com › Slang › RN.html
RN - Slang/Internet Slang
showing only Slang/Internet Slang definitions (Show all) Link/Page Citation · Page/Link Page URL: HTML link: Citations · MLA style: "RN." Acronym Finder. 2025. AcronymFinder.com 25 Nov. 2025 https://www.acronymfinder.com/Slang/RN.html · Chicago style: Acronym Finder.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › HTML › Element › br
<br>: The Line Break element - HTML | MDN
The HTML element produces a line break in text (carriage-return). It is useful for writing a poem or an address, where the division of lines is significant.