How do I properly embed "&" in HREF?

Skip Montanaro (
Sat, 25 Feb 1995 17:20:46 +0500

Sorry to bomb the list with this (especially since I don't read www-talk...)
but I'm getting desperate. I have what's got to be a common question, but
in several hours of hunting around the Web today and scrounging through
www-talk archives I haven't been able to get an answer to the following.

Is their one universally acceptable (I hesitate to use the term "correct")
way to embed "&" or other special characters in HREF attributes? Here's a
specific example: I generate lists of CGI-type anchors in response to a
number of different queries to the Musi-Cal database, for instance, <a

This worked fine until a WinMosaic 2.0.0a9 user reported that it wasn't
working. After scratching around off and on for a few days, I saw a note in
one of the comp.infosystems.www newsgroups that said to use "&amp;" instead.
I tried it. So now I have <a
Ridge</a>. Worked fine with Netscape 1.0N. (Doesn't everything?
<blink>:-)</blink>). Worked fine with X Mosaic 2.1 and Lynx 2.3 as well. I
checked with my user. Worked fine with him. Okey-dokey. Looks good. Into
production. Now another user's browser is choking on "&amp;" (can't recall
which one at the moment - it's sort of immaterial at this point). He
suggested "%26" instead. ARRRRGGGGH!

Before I make another apparently major blunder, is there a single
universally accepted version of "&" I can embed in my HREFs that the current
versions of all browsers (e.g., I really don't care about X Mosaic 2.1
anymore, although I still use it occasionally). Failing that, is there a
list somewhere of what the various browsers will accept?

I started writing Python code to handle all the friggin' HTTP_USER_AGENT
formats available -- what a mess! (HTTP_USER_AGENT, not Python) -- so I
could work around this problem dynamically. I have been laboring under the
assumption that the column labelled "CharAmpersand" in
<URL:> is
somehow related to this problem. If not, please let me know...

Help! (and thanks),

Skip Montanaro			  (518)372-5583
Musi-Cal: -or-
Internet Conference Calendar: