Search code examples
htmlinputname-attribute

Can I invent an html input name or is there a standardized list, for a simple web page?


I've researched this and not found this particular question answered -- I'm not asking specifically about form fillers but, for example, building a simple web page.

Is there a standardized list of input name attributes that will address all the possible options someone could put into their code?

This is an example:

<input type="radio" name="mobydick" />thewhale
<input type="radio" name="mobydick" />ahab

Thanks for your help!


Solution

  • According to the HTML5 specification, and in browser practice, the name attribute of an input element may have any nonempty string as its value, except that the values _charset_ and isindex have special predefined meanings.

    Server-side techniques used may impose their own restrictions and implications on the names.

    There are no standards on form field names. However, there were definitions of names that might be regarded as recommended names in HTML5 drafts. Although they were removed from the approved HTML5 specification due to lack of implementations, they have been retained in HTML 5.1 drafts, see clause on autofill in HTML 5.1 Nightly. The idea is that if different sites use the same names for commonly needed field types, browsers can autofill forms. E.g., after filling in your name, postal address, and date of birth on one page, your browser could automatically fill them in when you visit a page that asks for them, using the same names. Of course, such features come with risks, too.

    Thus, you may, at your discretion, use the names suggested there. They partly reflect common practices, such as using email for an e-mail address field and tel for a phone number field; partly they are just ideas of what might become “standard”.

    Yet another aspect is that if you use the GET method, the names will become visible to users in browser’s address bar after form submission. You might therefore wish to use descriptive names or, as the case may be, obfuscated names, depending on whether you want to make it easier to users to see what’s happening.