PHP Build a Basic PHP Website Listing and Sorting Inventory Items Breadcrumbs

Why don't we just put > instead of writing > ?

Why don't we just put > instead of writing > ?

Alena Holligan
Alena Holligan
Treehouse Teacher

Issues 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.

5 Answers

Jason Anders
MOD
Jason Anders
Treehouse Moderator 143,871 Points

Hey 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.

:dizzy:

Thanx 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
Trevor Wood
17,828 Points

In 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 &lt;h1&gt;hi&lt;/&gt; it will print <h1>hi</h1>

Moderator edited: Changed response from Comment to an Answer

Jason 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
Alena Holligan
Treehouse Teacher

sometimes it depends on how the server and encoding is set up. Often times you do not need to worry about special characters

Thanx Alena Holligan for your quick and awesome responses!