Underscores vs dashes in HTTP parameter names
Asked Answered
S

1

7

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?

Swainson answered 16/5, 2017 at 22:27 Comment(2)
Didn't know about that syntax highlighting feature @DaSourcerer, thanks!Swainson
few do. You're welcome ;)Headstock
H
11

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.

Headstock answered 16/5, 2017 at 22:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.