Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why should I use & instead of &?

why should I use & instead of & when writing HTML for my site?

Where can I find a list of other symbols that I should be encoding? (the bar / too, right?)

What problems could I have if I paste the symbol right as it is into the html?

The thing is, I have a few affiliate links and I'm worried that, if I write them with the & in some cases, for some reasons, because of the specific browser or device... that the info in the url wouldn't be passed correctly.

Hopefully someone can clear my mind?

Thanks!

like image 570
Il Magnus Avatar asked Feb 12 '16 16:02

Il Magnus


2 Answers

From https://developer.mozilla.org/en-US/docs/Glossary/Entity

HTML has a set of four reserved characters that must be represented as entities. All other characters can be represented with entities as needed, but it is not mandatory. These are the entities used for those four reserved characters :

  • & (&) - Required, so that a browser does not misinterpret it as the beginning of an entity.
  • &lt; (<) - Required because otherwise a browser could misinterpret it as the beginning of a tag
  • &gt; (>) - Required because otherwise a browser could misinterpret it as the ending of a tag
  • &quot; (") - Required only within attributes value surrender by quote sign

See here for a full list of all HTML character entities - https://dev.w3.org/html5/html-author/charref

like image 75
Jon Avatar answered Oct 18 '22 07:10

Jon


The character '&' is reserved word which has special purpose. That's why you have to use it in specific way.

Here you can find the HTML Entities. http://www.w3schools.com/html/html_entities.asp

like image 44
Muhammad Asad Ali Amjad Avatar answered Oct 18 '22 09:10

Muhammad Asad Ali Amjad