What's the point of the name
attribute on an HTML form? As far as I can tell, you can't read the form name on submission or do anything else with it. Does it serve a purpose?
The HTML <form> name Attribute is used to specify the name of a form Element. It is used to reference the form-data after submitting the form or to reference the element in a JavaScript.
The name attribute is probably the most important attribute of the <input> element. It isn't strictly required for validation, but you should never omit it. When a form is submitted to the server, the data from the form is included in an HTTP request. The data is packaged as a series of name-value pairs.
The <form> element also allows you to define method and action attributes, which tell the browser what to do when the form is submitted.
In short, and probably oversimplifying a bit: It is used instead of id
for browsers that don't understand document.getElementById
.
These days it serves no real purpose. It is a legacy from the early days of the browser wars before the use of name
to describe how to send control values when a form is submitted and id
to identify an element within the page was settled.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With