1
  1. Could anybody kindly explain me the difference or logic behind HTML5 id & name attributes of input & other elements.

  2. Should I define both or one is enough?

  3. Which one is required? id or name

Yohan Hirimuthugoda
  • 923
  • 3
  • 8
  • 18
  • 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 Answers1

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
  • 771
  • 1
  • 14
  • 26