Difference between id and name attributes in HTML

前端 未结 19 3277
感动是毒
感动是毒 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条回答
  •  星月不相逢
    2020-11-22 05:50

    Based on personal experiences and according to the W3 Schools description for attributes:

    ID is a Global Attribute and applies to virtually all elements in HTML. It is used to uniquely identify elements on the Web page, and its value is mostly accessed from the frontend (typically through JavaScript or jQuery).

    name is an attribute that is useful to specific elements (such as form elements, etc) in HTML. Its value is mostly sent to the backend for processing.

    https://www.w3schools.com/tags/ref_attributes.asp

提交回复
热议问题