What is the difference between the id
and name
attributes? They both seem to serve the same purpose of providing an identifier.
I would lik
There is no literal difference between an id and name.
name is identifier and is used in http request sent by browser to server as a variable name associated with data contained in the value attribute of element.
The id on the other hand is a unique identifier for browser, client side and JavaScript.Hence form needs an id while its elements need a name.
id is more specifically used in adding attributes to unique elements.In DOM methods,Id is used in Javascript for referencing the specific element you want your action to take place on.
For example:
Same can be achieved by name attribute, but it's preferred to use id in form and name for small form elements like the input tag or select tag.