Difference between id and name attributes in HTML

前端 未结 19 3273
感动是毒
感动是毒 2020-11-22 05:17

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

19条回答
  •  闹比i
    闹比i (楼主)
    2020-11-22 05:47

    Here is a brief summary:

    • id is used to identify the HTML element through the Document Object Model (via JavaScript or styled with CSS). id is expected to be unique within the page.

    • name corresponds to the form element and identifies what is posted back to the server.

提交回复
热议问题