Forum Moderators: open

Message Too Old, No Replies

"&" within a "<a href=" html link

Having text character "&" within a "<a href=" link

         

Alina

11:51 am on Apr 1, 2005 (gmt 0)

10+ Year Member



Hello

I am trying to get the following link to work:

<a href="hotel-directory-by-city.htm?area=Aberdeen & Region">Aberdeen & Region</a>

but the browser is naturally, interpreting the & part as starting a new key=value part.

Is there any way that i can get this link to work - whilst still keeping the "&" character?

Many thanks for your help

Alina

Alternative Future

12:02 pm on Apr 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Alina,

<a href="hotel-directory-by-city.htm?area=Aberdeen%20&%20Region">Aberdeen%20&%20Region</a>

&amp;#x26;%38 can be used to represent the ampersand &
so you could have either:

Aberdeen%20&amp;%20Region
or
Aberdeen%20%38%20Region

I would use option 1.

Is this what you mean?

-George

[edited by: Alternative_Future at 12:03 pm (utc) on April 1, 2005]

SoulAssassin

12:02 pm on Apr 1, 2005 (gmt 0)

10+ Year Member



you need to replace the & with &amp; but you also may have problems with the spaces in the link. If so try replacing these with %20.

So...

<a href="hotel-directory-by-city.htm?area=Aberdeen%20&amp;%20Region">Aberdeen & Region</a>

Longhaired Genius

12:09 pm on Apr 1, 2005 (gmt 0)

10+ Year Member



If the pages are under your control I would definitely not use spaces or and ampersand in the query string. If you have no choice in the matter you could try "percent encoding [ietf.org]" the problematic characters. The code for a space is %20 and the code for an ampersand is %26.

Alina

12:24 pm on Apr 1, 2005 (gmt 0)

10+ Year Member



Hi

Thank you all very much for your input. I reset the link to:

<a href="hotel-directory-by-city.htm?area=Aberdeen%20%26%20Region">Aberdeen & Region</a>

- and it worked!

Thanks again. Your help is much appreciated.

Alina

bruhaha

1:27 pm on Apr 1, 2005 (gmt 0)

10+ Year Member



&amp;#x26;%38 can be used . . . so you could have either:

Aberdeen%20&amp;%20Region
or
Aberdeen%20%38%20Region

and

%26

So which is it? %38 or %26... and what is that "#x26" all about?

Alternative Future

2:08 pm on Apr 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



>>So which is it? %38 or %26... and what is that "#x26" all about?

It's the one that worked for the poster!
<a href="hotel-directory-by-city.htm?area=Aberdeen%20%26%20Region">Aberdeen & Region</a>

I mistyped %30 (which is the decimal encoding for the ampersand) when it should have been %26 which another poster pointed out. My post said either use of &amp;%38 would work with my preferred option being the first. So by using the first all should have went well.

The #x26 is again another representation of the ampersand HEX value which can be used as &#x26;

-George