W3C home > Mailing lists > Public > www-validator@w3.org > April 2005

RE: Ampersands in URLs

From: iNaNimAtE <iNaNimAtE@cfxnetworks.com>
Date: Sat, 23 Apr 2005 12:45:29 -0700
To: "'David Dorward'" <david@dorward.me.uk>
Cc: <www-validator@w3.org>
Message-ID: <auto-000000300011@cfxnetworks.com>

My apologies--I am using XHTML (so used to just typing "HTML" I forgot the

Anyway, I read what you mentioned, and I guess it is either that or what I
am doing now, but my current method does not seem all that bad.

-----Original Message-----
From: David Dorward,,, [mailto:david@us-lot.org] On Behalf Of David Dorward
Sent: Saturday, April 23, 2005 12:30
To: iNaNimAtE
Cc: www-validator@w3.org
Subject: Re: Ampersands in URLs

On Fri, Apr 22, 2005 at 06:57:41PM -0700, iNaNimAtE wrote:
> I am having a problem validating with an ampersand in a URL. In normal
> I encode it into &amp;, but in JavaScript, I have to keep it as "&" making
> the page invalid.

In HTML, <script> elements contain CDATA and ampersand characters are
perfectly OK. 

It is a lot easier to help debug problems when presented with an
example of troublesome code, but I'll hazard a guess that you are in
fact using XHTML and not HTML.

If so, then I draw your attention to section 4.8 of the XHTML 1.0


You could encode your ampersands as &amp; even inside <script> blocks
in XHTML - although this would break HTML computability so you
wouldn't be able to serve your XHTML under the text/html content-type.

David Dorward                                      http://dorward.me.uk
Received on Saturday, 23 April 2005 19:45:39 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:58:50 UTC