3

I use the URL below in my web page in href tag and unfortunatelly whole link fails in W3C HTML/XHTML Validation.

How do I solve this problem?

http://maps.google.co.uk/maps?q=N+Z&hl=en&hnear=ABC+N4+1,+Jamaica&t=m&z=16

My page includes:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
.
.
.
3
  • Would be helpful if you included the validation error Commented Oct 26, 2012 at 17:17
  • + is not a valid URL character change it to %2B Commented Oct 26, 2012 at 17:19
  • Reference not terminated by REFC delimiter. - Reference to external entity in attribute value. - An unknown entity has been used. This often happens when &param=value is used instead of &amp;param=value in URL query strings - In HTML the ampersand character (&) is reserved for marking character entities so you should never use raw ampersands in HTML - including ampersands inside URLs. For example, any URL that needs an ampersand should look like: example.com/… Commented Oct 26, 2012 at 17:19

2 Answers 2

5

You'd have to encode the ampersand (&) in URLs with &amp;.

So your URL should look like:

http://maps.google.co.uk/maps?q=N+Z&amp;hl=en&amp;hnear=ABC+N4+1,+Jamaica&amp;t=m&amp;z=1

See info in HTML 4.01, for example. Also there is web tool which checks for ambiguous ampersands: http://mothereff.in/ampersands

Sign up to request clarification or add additional context in comments.

Comments

2

You should escape/encode the URL.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.