Underscores vs dashes in HTTP parameter names

12.2k views Asked by At

I'm familiar with the convention of using hyphens to separate words in URL paths. What about parameter names, such as within a <form>:

<form>
  <input name="my_special_field">
</form>

is that better or my-special-field? I've seen Google use underscores in analytics with utm_campaign and other parameter names. Underscores read a little better and allow for the occasional hyphen within the name (field_for_5-16-17). But hyphens are certainly the convention for URL paths.

What's the convention for separating words in an HTTP parameter name?

1

There are 1 answers

0
DaSourcerer On BEST ANSWER

What's the convention for separating words in an HTTP parameter name?

Well, I think there is none. I hear hyphens perform a bit better SEO-wise. But as long as you are compliant with RFC 3986 (especially section 3.4), everything is okay.

If it really interests you, part of the dilemma is that the query string has never been formalized. There is only a consensus on which characters are supposed to be allowed in it.