Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is "name" attribute mandatory in <input>, <textarea> and <button> elements?

Is "name" attribute mandatory in <input>, <textarea> and <button> elements? Or maybe we can use id or class instead?


1 Answers

  • If these tags are inside a form tag and you are subbmitting that form to a server, then name is required,
  • If you are just using them for client-side purposes and don't want to send them to server, then it is optional.
like image 81
Vlas Bashynskyi Avatar answered Oct 23 '25 21:10

Vlas Bashynskyi