ampersands in URLS in XML compliant HTML

I have a problem with ampersands in URL's that use ampersands.

The use of ampersand is kind of important in a URL. You probably know this already but the ampersand in a URL often to set GET parameters for a request to a server side script.

The problem is that it seems XML needs all ampersands to be written of the form & but I don't think the JavaScript below would work then.

Here is an example of some code I'm referring to. You can see the "&url=" that causes the problem.
<a onclick="'/cgi-bin/'...

How can you use ampersands in attribute values of XML compliant code?


  • The javascript worked both ways on IE and FF, just try it ;)
    But it's definitely correct to use & in this context, though. Not using it is incorrect. It would also be correct to use the unicode codepoint for the ampersand - &

    It's always a good idea to run your html through a good validator, it's amazing how many mistakes can be found in html that otherwise looks perfect :)
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion