Is it redundant to use the "name" attribute for input fields in modern web development?
forms, html, input
Solution
The `name` attribute is the notation to reference specific elements within the scope of a webpage through non-DOM Javascript:
document.forms['your_form'].elements['aa']
The `id` attribute for the element needs to be set with the same value for the following to work:
document.getElementById('aa')
My understanding is that when Netscape created Javascript, it used the `name` attribute. The HTML spec however decided to go with `id`, but kept `name` for backwards compatibility. IME, using the `name` attribute was required for Internet Explorer 6 support because the javascript engine in IE wouldn't read the `id` attribute - only the `name` though both were defined.
...could be avoided the use of this attribute with input fields of "text" type (when there aren't no styling or scripting purposes)?
If you don't have any javascript attached to the text fields, yes - they would be unnecessary.
Problem
I've noticed a lot of websites with form(s) containing input fields whose "name" attribute is specified even if it isn't used for styling or scripting purpose! Moreover, according to the official document about the form in HTML document ... name = cdata [CI] This attribute names the element so that it may be referred to from style sheets or scripts. Note. This attribute has been included for backwards compatibility. Applications should use the id attribute to identify elements. So, my question is: should this attribute used only for styling and scripting purposes? Thanks in advance! EDIT: In particular, could be avoided the use of this attribute with input fields of "text" type (when there aren't no styling or scripting purposes)? EDIT 2: So, you have almost confirmed what I had thought about: the "name" attribute will be deprecated in further HTML specifications/standards!!!??? It is still "alive" only `for backwards compatibility` ... in some cases can be avoided but there are still some cases (such as the radio button) where it is necessary!