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 trialKeith Colleluori
9,577 PointsWhy does using <br> or just the <li> elements fail? The output is exactly the same on my screen afaik, as \n
I do not think I understand what \n does. Every time I encounter it, it seems to trip me up. As I said in the heading, when I made the material appear the same using, html <br> or the <li> with no \n or <br> I failed. Even though it appears exactly the same as far as I could tell it didn't pass.
What is \n telling me? Is it a new line for coding, and not for output? Is that what I am not getting?
1 Answer
filipepacheco
Full Stack JavaScript Techdegree Student 21,416 PointsThe \n will add a line break to the source code output, and <br> tag will add a line break to the resulting visual display. So the \n will not work in the browser, but if you try to view the page source or run the file on a terminal, you will see that it works.
Keith Colleluori
9,577 PointsKeith Colleluori
9,577 Pointsthank you for your response. So the purpose of the \n is for the cleanliness of the code on the backend?
filipepacheco
Full Stack JavaScript Techdegree Student 21,416 Pointsfilipepacheco
Full Stack JavaScript Techdegree Student 21,416 PointsExactly. It makes it easier to read the code.