Descripción
Mediante el atributo form podemos asociar la gestión de un formulario al botón para poder enviar el formulario. Esto nos permite tener el botón sin estar anidado dentro del elemento form. El valor del atributo form será el id de un formulario.
Sintaxis
<button form="idform">Texto Botón</button>
Elemento Padre
Ejemplo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Asociar botón a formulario</title>
</head>
<body>
<form id="miformualario" method="get" action="send">
<label for="nombre">Nombre: </label>
<input type="text" name="nombre" id="nombre"/>
</form>
<button id="miboton" form="miformualario">Enviar</button>
</body>
</html>
Artículos
Vídeos HTML
Disfruta también de nuestros artículos sobre HTML en formato vídeo. Aprovecha y suscribete a nuestro canal.