On ampersands in query strings (was: HTML entities in URLs and urlencoding)

Aristotle Pagaltzis pagaltzis at gmx.de
Tue Apr 1 00:45:42 EDT 2008

* Waylan Limberg <waylan at gmail.com> [2008-04-01 03:50]:

> As far as I can tell, the "&amp;" breaks the query string.

No, it doesn’t, as you found out.

However, on a tangential note: if you write web apps, *please*
make sure that you support the semicolon as a query parameter
separator as well as the ampersand:


More importantly, please **please** make sure that the URIs your
code generates use semicolons rather than ampersands. Semicolons
need not be escaped in HTML and XML, which makes copy-pasting
users much less likely to produce invalid markup regardless of
the context they’re working in.

Even though this W3C recommendation is over a decade old, use of
ampersands in query strings persists. (In fact, PHP not only does
not emit URIs with semicolon-separated query strings, by default
it cannot even parse them! You need to set an unbreak-me config
option to make it recognise the semicolon.)

Aristotle Pagaltzis // <http://plasmasturm.org/>

More information about the Markdown-Discuss mailing list