I'm passing variables through the URI string, like this:


Everything works as intended, but when I pass the source code through the W3 validator, it's flagging them as errors. When I quote the variables, like this:


they do not get flagged. I've never seen a website do this, but is that the proper way to pass these variables? I could not find any source that recommends quoting them in the URI.

  • 1
    What are you validating? The URL with the parameters or a page that links to it? Dec 22, 2015 at 21:14
  • I'm validating the page that contains the links. So, the code that's getting flagged would be something like: <a href="link.php?a=first&b=second">Click here!</a> But it doesn't get flagged when written like this: <a href="link.php?a='first'&b='second'">Click here!</a>
    – user58934
    Dec 22, 2015 at 21:30
  • That doesn't make much sense, can you post the exact code and error message that the W3C Validator is reporting? Also (if it matters) what DOCTYPE are you validating to?
    – MrWhite
    Dec 22, 2015 at 21:43
  • Here's the actual code: <a href="../show_initiative.php?id=19&a=yes"> The validator throws four errors: "No space between attributes," "Saw " when expecting an attribute name. Probable cause: = missing immediately before.", "Attribute " is not serializable as XML 1.0.", and "Attribute " not allowed on element a at this point." The page is HTML5. The validator reports: "The Content-Type was text/html. Using the HTML parser." and "Using the schema for HTML with SVG 1.1, MathML 3.0, RDFa 1.1, and ITS 2.0 support."
    – user58934
    Dec 22, 2015 at 21:48
  • 1
    Thanks, all! A follow up, for those who are interested. This line gets flagged: <a href="../show_initiative.php?id=19&a=yes">, but these (yes, both of them) do not: <a href="../show_initiative.php?id=19&amp;a=yes"> and <a href="../show_initiative.php?id='19'&a='yes'">
    – user58934
    Dec 22, 2015 at 22:13

1 Answer 1


<a href="link.php?a=first&b=second">Click here!</a>

The only thing that might get flagged in that anchor is the unencoded &. The & should be HTML encoded. ie. &amp; (in order to avoid potential conflict). URL parameters certainly should not be quoted as a general rule.

The URL, by its very nature, is all a "string", so quoting URL parameter values for the sake of it does not make sense, unless you explicitly needed this for your script (although this should probably be avoided, as it just adds clutter). If you quote a URL parameter value then the quotes themselves become part of the value, they do not delimit the value itself.

  • Thanks for the tip--you've answered my question. I like to keep things simple, and in this case, it seems that I can.
    – user58934
    Dec 22, 2015 at 21:46

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.