HTML – Why Ampersand is a HTML Entity

entityhistoryhtml

I understand the rationale behind why most of the HTML character Entities were created, but I don't understand the purpose behind the ampersand HTML entity. & contains more bits than a & symbol, and it even has the & inside it already!

Why was it decided that ampersands should be encoded in the format that requires more data, instead of just using the symbol?

Best Answer

To avoid ambiguity. Suppose you want to write a website about HTML. You write the line: "To write a literal < you have to write &lt;." Now, to write that down in HTML:

<p>To write a literal &lt; you have to write &lt;.

... oops. To make it work, you have to have some way to distinguish the character & from the HTML syntax starting with &. So that's why you have to write:

<p>To write a literal &lt; you have to write &amp;lt;.

... which renders correctly.