Difference between id and name attributes in HTML

前端 未结 19 3180
感动是毒
感动是毒 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 06:02

    ID is used to uniquely identify an element.

    Name is used in forms.Although you submit a form, if you dont give any name, nothing will will be submitted. Hence form elements need a name to get identified by form methods like "get or push".

    And the ones only with name attribute will go out.

提交回复
热议问题