Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial

agung laksana
Courses Plus Student 179 Pointswhat is the difference between </br> and \n ?
hi,
what is the difference between </br> and \n ? like this
i get confused with these two, it seems they have similar function. Thanks :)
1 Answer

Steven Parker
242,796 PointsThe tag "<br>" is HTML code that causes a line break on the page. But "\n" is a character escape sequence that represents a newline character.
They would generally be found in different places. In an HTML file, you would see "<br>" but not "\n". But in script code, you would see "\n" used for console messages. You might also see "<br>" but only if the purpose of the script is to create or modify HTML.
agung laksana
Courses Plus Student 179 Pointsagung laksana
Courses Plus Student 179 Pointsthanks Steven, I have edited my question. I am following PHP course and I see </br> and \n like this https://imgur.com/a/Iqg4D
i see both used in the script
Steven Parker
242,796 PointsSteven Parker
242,796 PointsThis script code is generating HTML. The "<br />" code will cause the browser to display the following text on a new line, but the "\n" will actually add a newline into the HTML file. The latter one will not be displayed on the browser page and will only be seen by someone viewing the page source.
Using both keeps the source looking similar to the final page. You'll notice that the
h2
element in your example has only the "\n" because header elements take up an entire line by default when the browser displays them.