W3C home > Mailing lists > Public > www-validator@w3.org > February 2000

Re: Ampersand trouble?

From: Harold A. Driscoll <harold@driscoll.chi.il.us>
Date: Mon, 14 Feb 2000 10:53:01 -0600
To: "Clark Kimberling" <ck6@evansville.edu>
Cc: <www-validator@w3.org>
Message-Id: <20000214170106.QFEP12275.mta1@mallard>
At 10:08 14-02-00 , Clark Kimberling wrote:
>and got the impression that URIs which contain Ampersands 
>(&'s) may have some problems.

The problem with Ampersands (&) is a widespread misunderstanding of HTML...
and the authors of some incomplete HTML texts (who'll remain nameless)
merit more than a smidgen of the ~credit~.

In all HTML documents, the character & has a special meaning, such as &lt;
(or sometimes &lt) to indicate the less-than (<) character. Therefore,
whenever you want to represent the & character, it must be represented as
&amp; (or sometimes &amp).

Since within a URI is where ampersands are most commonly used, this is
where the issue is most evident.

If you change (fix) your URIs, such as

	HREF="http://host.tld/cgi/electricity.pl?amp=2&watt=3&volt=4"

into

	HREF="http://host.tld/cgi/electricity.pl?amp=2&amp;watt=3&amp;volt=4"

You'll be all set. As an aside, note that in this contrived example, were
you to change the order of the parameters (quite legitimate), the misuse of
& would not only fail to validate but fail to run as expected. <g>

>Unfortunately, upon clicking the link offered at the above 
>address in connection with Ampersands, I received a 
>"Page cannot be displayed" message.

Oops, Perhaps a network error occurred (link or server down), perhaps a bad
link. Thanks for pointing out that problem. (Said with the luxury of not
being to one who needs to research and fix it, grin).

>Can I validate a page that uses lots of &'s?  It's a 
>mathematical page with lots of Greek symbols and other 
>&goodies, so I really must use &'s.  I'd
>really like, also, to be able to display the Validated logo.

Oh, sure... just make sure you ~quote~ all literal & symbols as &amp;

Will it validate right on the first time, with lots of pesky &s? I'll make
no predictions for your fingers, but know better that to expect same (on
first try) of mine. <g>

Safe computing,  /Harold
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Harold A. Driscoll                 mailto:Harold@Driscoll.Chi.IL.US
#include <std/disclaimer>                 http://Driscoll.Chi.IL.US
Received on Monday, 14 February 2000 12:01:07 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 25 April 2012 12:13:53 GMT