What is the difference between \n in the source code and HTML line breaks?

In source code, \n represents a newline character that is used for formatting and readability within the code itself. However, in HTML, line breaks are represented by the <br> tag, which is used to create line breaks in the displayed content on a webpage. When outputting text in HTML, it is important to use <br> tags instead of \n to ensure that line breaks are displayed correctly in the browser.

&lt;?php
$text = &quot;This is a line of text.\nThis is another line of text.&quot;;
echo nl2br($text);
?&gt;