0

Since there is things like BEM in naming conventions for HTML class attributes, does the name attribute have anything of that sort?

3

Name is a CDATA type so the following applies:

ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").

Despite that there are cautions offered by StackExchange users:

StackOverflow Question: "HTML input - name vs. id", in answer from Kumar Akarsh:

  • According to specs is case sensitive, but most modern browsers don't seem to follow this.

w3schools - "HTML Forms" cautions:

The Name Attribute

Each input field must have a name attribute to be submitted.

If the name attribute is omitted, the data of that input field will not be sent at all.

Mozilla's documentation (if you drill down from): "MDN web docs - HTML attribute reference" to "MDN web docs Moz://a - <form>" says:

  • name - The name of the form. In HTML 4, its use is deprecated (id should be used instead). It must be unique among the forms in a document and not just an empty string in HTML 5.

Mozilla.Org also refers you to: HTML - Living Standard — Last Updated 21 August 2018

"The name attribute represents the form's name within the forms collection. The value must not be the empty string, and the value must be unique amongst the form elements in the forms collection that it is in, if any.".

So ...

You probably want all lowercase with each word (if there's more than one) separated by a dash (rather than camelCase).

| improve this answer | |
1

There is no such naming convention in HTML for name attribute as well as for other attributes also. But you should follow the following rules.

  1. Use lowercase Latin letters.
  2. Separate different words by a hyphen.
  3. Do not use periods as well as numbers at the beginning of the name.
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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