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 trialWenqian Guo
2,612 Points&
we use & to display & in html in case the browser can't recognize &? Is that correct? Or is that just a html way of displaying &??Do we have to do that for all symbols???
1 Answer
John W
21,558 PointsYes, because the ampersand (&) by itself starts an escaping sequence that the browser will convert to whatever symbol it means. Another example would be the less-than symbol (<). By itself it means the beginning of a tag, so if you just have it in your HTML the browser would assume a tag follows, and nothing would get displayed. To display the actual symbol, you would do <
.
Thus, any symbol that is either reserved (<, >, &, ', ") or "weird" (e.g. รท, ร) should be displayed by escaping with &
. And since &
itself is reserved for escaping, you would display it with &
instead of just having it in your HTML text file.