Page 1 of 1
To & or &, that is the question..
Posted: Thu Nov 12, 2009 1:28 pm
by Kev
When writing XHTML, specifically creating anchor tags for links, should you use html entities for characters in URL's like &?
For instance... if I'm writing XHTML, which is correct?
Code: Select all
<a href="http://www.example.com/index.php?a=2&z=9">Link</a>
or
Code: Select all
<a href="http://www.example.com/index.php?a=2&z=9">Link</a>
I never could quite figure this out. Thanks!
Re: To & or &, that is the question..
Posted: Thu Nov 12, 2009 1:49 pm
by alex.barylski
Run your code through a validator and find out?
p.s-It's the latter form I do believe.
Cheers,
Alex
Re: To & or &, that is the question..
Posted: Thu Nov 12, 2009 2:06 pm
by Kev
I tried but the validator doesn't address entities in URL's.
Re: To & or &, that is the question..
Posted: Thu Nov 12, 2009 2:34 pm
by jackpf
It should.
Re: To & or &, that is the question..
Posted: Thu Nov 12, 2009 4:37 pm
by alex.barylski
Might depend on which doctype you have defined? I am quite sure that even transitional will error if & is not used in URI.
Re: To amp or meta amp, that is the question..
Posted: Sun Nov 15, 2009 10:58 pm
by josh
Just be aware if you don't put & you run the risk of suffixing an ampersand with characters that happen to collide with a valid actual html entity. For instance if you had a URI parameter called 'copy', and you wrote © the browser would get confused
Did you mean © ( as in a ampersand followed by the word 'copy' followed by a semi-colon)
or did you mean © (as in the actual copyright symbol)
So you see it is better to write & than &, not just because some validator says so, but because it is more bullet-proof.
Re: To & or &, that is the question..
Posted: Sun Nov 15, 2009 11:05 pm
by John Cartwright
Although slightly unconventional, you are better off using a different character other than & anyways (which can be configured in apache).
Re: To & or &, that is the question..
Posted: Mon Nov 16, 2009 5:18 am
by josh
How does that affect SEO?