What's the point of HTML forms `name` attribute?

后端 未结 6 1800
情歌与酒
情歌与酒 2020-12-05 09:01

What\'s the point of the name attribute on an HTML form? As far as I can tell, you can\'t read the form name on submission or do anything else with it. Does it

6条回答
  •  攒了一身酷
    2020-12-05 09:40

    Here's what MDN has to say about it:

    name
    The name of the form. In HTML 4, its use is deprecated (id should be used instead). It must be unique among the forms in a document and not just an empty string in HTML 5.

    (from https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form#attr-name)

    I find it slightly confusing that specifies that it must be unique, non-empty string in HTML 5 when it was deprecated in HTML 4. (I'd guess that requirement only applies if the name attribute is specified at all?). But I think it's safe to say that any purpose it once served has been superseded by the id attribute.

提交回复
热议问题