What are the needs of keeping a `name` attribute in an `HTML` tag?


What are the needs of keeping a name attribute in an HTML tag? its characteristics are the same as the id attribute which still has other uses such as being the key of the PHP $_POST and $_GET arrays.



Generally, the name attribute serves to represent a collection of values, sent through a form, to the server.

Other Utilities

Submission of forms to IFRAMES

Ricardo, in addition to serving as keys for POST and GET , another feature I know of is to make a form submission to an iframe , instead of updating the page.


<form target="meu_iframe" action="form.php">
  <input type="text" name="nome" />
  <input type="submit" />

<iframe name="meu_iframe">

Consequently, when the form is submitted, the result will be displayed in the iframe instead of updating the page. Even though the action is pointing to another page, its rendering will be inside the iframe .

This is a feature I know of. Maybe there could be others, let's see the other answers 🙂

Accessing the Form Via Javascript

I also remember that it is possible to give a name to a form, even if it is not processed by the server (as stated in one of the answers)

Is it possible to do that:

<form name="matricula">

So, we can access this form easily through Javascript:

Scroll to Top