Whats the difference between & and & in HTML5?

Bhimbim picture Bhimbim · Apr 3, 2013 · Viewed 50.9k times · Source

What is the difference between & and &?

Like in the code bellow, are both working in the same way?

<a href="mailto:EMAIL?subject=BLABLABLA&body=http://URL, SHORT DESCRIPTION"></a>
<a href="mailto:EMAIL?subject=BLABLABLA&amp;body=http://URL, SHORT DESCRIPTION"></a>

Answer

Chuck picture Chuck · Apr 3, 2013

In HTML5, they are equivalent in that example. Traditionally, in HTML, only &amp; was correct — but as with so many things, web developers blithely ignored this inconvenient rule and wrote bare ampersands everywhere. For their part, browsers just "did the right thing" and interpreted these ampersands as ampersands. HTML5 standardized this behavior, so now & is allowed by itself as long as what goes afterward does not look like an entity reference.