Atributo de formulario HTML <botón>

❮ Etiqueta HTML <botón>

Ejemplo

Un botón ubicado fuera de un formulario (pero que sigue siendo parte del formulario):

<form action="/action_page.php" method="get" id="form1">
<label for="fname">First name:</label>
<input type="text" id="fname" name="fname"><br><br>
<label for="lname">Last name:</label>
<input type="text" id="lname" name="lname">
</form>

<button type="submit" form="form1" value="Submit">Submit</button>

Definición y uso

El formatributo especifica el formulario al que pertenece el botón.

El valor de este atributo debe ser igual al idatributo de un <form> elemento en el mismo documento.


Compatibilidad con navegador

Los números de la tabla especifican la primera versión del navegador que es totalmente compatible con el atributo.

Attribute
form 10.0 16.0 4.0 5.1 9.5

Sintaxis

<button form="form_id">

Valores de atributo

Value Description
form_id Specifies the form element the <button> element belongs to. The value of this attribute must be the id attribute of a <form> element in the same document.

❮ Etiqueta HTML <botón>