[thelist] Ampersands in URLs

aardvark roselli at earthlink.net
Sat Oct 12 13:56:11 CDT 2002


> From: "Clive R Sweeney" <clive at designshift.com>
>
> A few of my pages have hyperlinks with URLs containing ampersands.
> This yields an "unknown entity" error in the W3C Validator. It's not a
> big deal, but just to tidy up, is there an easy way to escape the
> ampersand?

<a href="http://foo.bar/foo.asp?foo=bar&amp;bar=foo">feh</a>

just convert '&' to '&amp;'...

if you're pulling links in dynamically, use your server-side language
to encode the string -- in ASP, you could use server.HTMLEncode()...
most languages have a provision for handling this...

--
Read the evolt.org case study
Usability: The Site Speaks for Itself
http://amazon.com/exec/obidos/ASIN/1904151035/evoltorg02-20
ISBN: 1904151035





More information about the thelist mailing list