HTML <input> valueAtributo
Ejemplo
Un formulario HTML con un valor inicial (predeterminado):
<form action="demo_form.php">
First name: <input type="text" name="fname" value="John"><br>
Last name: <input type="text" name="lname" value="Doe"><br>
<input type="submit" value="Enviar formulario">
First name: <input type="text" name="fname" value="John"><br>
Last name: <input type="text" name="lname" value="Doe"><br>
<input type="submit" value="Enviar formulario">
Pruébalo »
Compatibilidad con navegadores
![]()
![]()
![]()
![]()
![]()
Todos los navegadores principales admiten el atributo value.
Definición y uso
El atributo value especifica el valor del elemento <input>.
El atributo value tiene diferentes usos según el tipo de input:
- Para los tipos "button", "reset" y "submit" - define el texto en el botón.
- Para los tipos "text", "password" y "hidden" - define el valor inicial (predeterminado) del campo de entrada.
- Para los tipos "checkbox", "radio" e "image" - define el valor asociado con el elemento input, que se envía a la URL de acción del formulario al enviarlo.
Nota:El atributo value es obligatorio para <input type="checkbox"> y <input type="radio">.
Nota:El atributo value no se aplica a <input type="file">.
Diferencias entre HTML 4.01 y HTML5
Ninguna.
Sintaxis
<input value="text">
Valor de atributo
| Valor | Descripción |
|---|---|
| text | Especifica el valor del elemento <input>. |
Etiqueta HTML <input> Otras extensiones