Forum Moderators: open

Message Too Old, No Replies

ampersands in urls

clarification needed

         

HelenDev

3:24 pm on Nov 21, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm trying to do some error fixes on our site and am running pages through the validator. Many of the errors I am getting seem to be to do with ampersands in urls.

For example I have some external links which look something like this

<a href="http://www.somedomain.co.uk/main?pageName=foo&Action=location_uri&select_location=abc">

Would I be correct in thinking that in order to make this validate I should always retype these links to be like this

<a href="http://www.somedomain.co.uk/main?pageName=foo&amp;Action=location_uri&amp;select_location=abc">

If anyone can confirm whether I am understanding this right or offer any further explanation I would be grateful. The validator does offer some sort of explanation but frankly my brain on a Monday afternoon is not up to deciphering it.

le_gber

4:08 pm on Nov 21, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I think I can safely say that you are right in your assumptions ;-)

Robin_reala

7:29 pm on Nov 21, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In way of further explanation, ampersand symbols are always used to start character entities in SGML and XML. Character entities are a way of getting unusual characters into your document when using a character set that doesn't natively have them. For example, &pound; will translate on screen to the £ symbol. Because of this you need to translate the & symbol into it's own character reference, namely &amp;. This must be done on all ampersands on the page because any of them could be the start of aa character entity.

innocbystr

6:26 am on Nov 22, 2005 (gmt 0)

10+ Year Member



I'm fairly new to all this but have learned a lot from fixing the code in a lot of affiliate banner ads and external links so that it will validate. The ampersand seems to be the most common error. It's hard to believe in this day and time that people actually get paid write obsolete garbage.