Could anybody kindly explain me the difference or logic behind HTML5 id & name attributes of input & other elements.
Should I define both or one is enough?
Which one is required? id or name
Asked
Active
Viewed 1,150 times
1

Yohan Hirimuthugoda
- 1,053
- 3
- 11
- 20
-
I think answer to my question available under: https://stackoverflow.com/questions/10165908/html-5-difference-input-id-and-input-name Obtain from that post: In short, the name is the identifier that is sent to the server when you submit the form. The id is a unique identifier for the browser, client-side, for JavaScript and such. Further more id attribute is for uniquely identifying any element (not just form elements). It must be unique throughout the entire document. – Yohan Hirimuthugoda Jan 31 '18 at 06:47
-
@BoldClock I think duplicate of this: https://stackoverflow.com/questions/10165908/html-5-difference-input-id-and-input-name rather than https://stackoverflow.com/questions/1397592/difference-between-id-and-name-attributes-in-html – Yohan Hirimuthugoda Jan 31 '18 at 06:49
1 Answers
2
Sometimes, both can be used for the same purpose. But, Normally id attribute is used to call that element. and name attribute is used when you send a data to some other page from a form through post or get method, then we can access to the data of that element through that name.

Tazwar Utshas
- 921
- 2
- 17
- 30
-
1No, the purpose of name and id is not the same anywhere; it hasn't been since last century. – Mr Lister Jan 31 '18 at 07:35
-