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 trialNick Winner
615 PointsWhy don't we just put > instead of writing > ?
Why don't we just put > instead of writing > ?
5 Answers
Jason Anders
Treehouse Moderator 145,860 PointsHey Nick,
Alena provides a link in the Teacher's Notes on HTML Special Characters (or HTML entities). As is stated in the link: "HTML Entities and/or ISO Latin-1 codes can be placed in source code like any other alphanumeric characters to produce special characters and symbols that cannot be generated in HTML with normal keyboard commands."
Basically, anytime a character has a chance of being mis-interpreted by the editor or browser when it's rendering the file, you will want to use an entity. In your example, if your were to just use the character > instead of the character code, the browser would probably interpret it as an orphaned HTML tag, which would result in an error.
It's the same thing with single and double quotes. This could be interpreted as being used to enclose a completed string, so when you use one, it is possible a second one could be looked for, and when not found... error out (this is less common).
Special characters are very common and very often used, so I do recommend you check out the link Alena provided.
Nick Winner
615 PointsThanx Trevor Wood for your answer. My question was related with this video for writing Breadcrumbs https://teamtreehouse.com/library/build-a-basic-php-website/listing-and-sorting-inventory-items/breadcrumbs
The same thing Alena Holligan does in this video by writing &rsquo instead of just putting ' symbol. https://teamtreehouse.com/library/build-a-basic-php-website/adding-a-basic-form/setting-up-the-initial-form I am a little confused :(
Trevor Wood
17,828 PointsIn what situation are you needing to do that?
In general, you need to write
>
when you don't want something to be executed in code.
for example,
if you echo <h1>hi</h1> it will print a header 1 with hi
but if you echo <h1>hi</> it will print <h1>hi</h1>
Moderator edited: Changed response from Comment to an Answer
Nick Winner
615 PointsJason Anders , thanx for your response! However i didn't use any of HTML entities, you and Alena Holligan mentioned, and my code still gets "No errors/warnings" on W3C Validation. Is this just a recomendation?
Alena Holligan
Treehouse Teachersometimes it depends on how the server and encoding is set up. Often times you do not need to worry about special characters
Nick Winner
615 PointsThanx Alena Holligan for your quick and awesome responses!
Alena Holligan
Treehouse TeacherAlena Holligan
Treehouse TeacherIssues with HTML display.
By using ">" html thinks you are closing an html tag. By using ">" we tell html we want to use this specific character, and we are not trying to close a tag.