Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

<input type ="button">

Esta traducción está incompleta. Por favor, ayuda a traducir este artículo del inglés.

El elemento HTML <input type="button"> es una versión específica del elemento <input>, que se usa para crear un botón en el que se puede hacer click sin ningún valor por defecto. Ha sido sustituido en HTML por el elemento <button>.

Los navegadores generan un controlador para un botón clickable sin valor por defecto. El botón puede tener cualquier texto. El controlador en sí varía con respecto de un navegador a otro.

Content categories Contenido de flujo, contenido de estilo, contenido interactivo, listado, etiquetable, y elementos entregables con contenido asociado a los formularios, contenido evidente.
Contenido permitido Contenido de estilo.
Omisión de etiquetas Ninguna, las etiquetas de inicio y cierre son obligatorias.
Elementos padre permitidos Cualquier elemento que acepte contenido de estilo.
Interfaz DOM HTMLButtonElement
Tipo de elemento Inline

Atributos

Este elemento puede tener cualquiera de los atributos globales además de los siguientes:

disabled

Este atributo booleano indica que el usuario no puede interactuar con el botón. Si este atributo no está especificado, el botón hereda su configuración del elemento contenedor, por ejemplo, <fieldset>; si no hay elemento contenedor con el atributo disabled establecido, el botón estará habilitado. El valor de control desactivado no está activado con el formulario y el evento click no será enviado en los controles desactivados.

Firefox, al contrario que otros navegadores, mantiene por defecto el estado de desactivación dinámico de un <button> a lo largo de las cargas de la página. Use el atributo autocomplete para controlar esta característica.

autofocus HTML5
Este atributo booleano le permite especificar que el botón deba tener el foco cuando la página se cargue, a no ser que el usuario lo ignore, por ejemplo, escribiendo en otro cuadro de texto. Únicamente un elemento asociado con los formularios en un documento puede tener este atributo especificado.
autocomplete
El uso de este atributo en un <button> es algo fuera de lo común, y específico de firefox. Firefox, por defecto y al contrario de otros navegadores, mantiene por defecto el estado de desactivación dinámico de un <button> a lo largo de las cargas de la página. Establecer el valor de este atributo a off (autocomplete="off") desactiva esta característica.
form HTML5
El elemento del formulario con el que el botón está asociado (es dueño del formulario). El valor del atributo debe ser el atributo id de un elemento <form> en el mismo documento. Si este atributo no está especificado, el elemento <button> debe ser hijo de un elemento "formulario". Este atributo le permite colocar elementos <button> en cualquier lugar de un documento, y no únicamento como hijos del elemento <form>.
formenctype
Ya que el elemento de input es un botón de envío, el atributo formenctype especifica el tipo de contenido que se usa para enviar el formulario al servidor. Los valores posibles son:
  • application/x-www-form-urlencoded: Valor por defecto si el atributo no se especifica.
  • multipart/form-data: Este valor se usa si un elemento <input> es usado con el atributo type fijado a file.
  • text/plain

Si este atributo se especifica, ignora el atributo enctype del botón del dueño del formulario.

formaction HTML5
The URI of a program that processes the information submitted by the button. If specified, it overrides the action attribute of the button's form owner.
formmethod
Since the input element is a submit button, the formmethod attribute specifies the HTTP method that the browser uses to submit the form. Possible values are:
  • post: The data from the form is included in the body of the form and is sent to the server.
  • get: The data from the form is appended to the form attribute URI, with a '?' as a separator, and the resulting URI is sent to the server. Use this method when the form has no side-effects and contains only ASCII characters.

If specified, this attribute overrides the method attribute of the element's form owner.

formnovalidate
Since the input element is a submit button, the formnovalidate attribute specifies that the form is not to be validated when it is submitted. If this attribute is specified, it overrides the novalidate attribute of the element's form owner. This is a Boolean attribute.
formtarget
Since the input element is a submit button, the formtarget attribute is a name or keyword indicating where to display the response that is received after submitting the form. This is a name of, or keyword for, a browsing context (for example, tab, window, or inline frame). If this attribute is specified, it overrides the target attribute of the element's form owner. The following keywords have special meanings:
  • _self: Load the response into the same browsing context as the current one. This value is the default if the attribute is not specified.
  • _blank: Load the response into a new unnamed browsing context.
  • _parent: Load the response into the parent browsing context of the current one. If there is no parent, this option behaves the same way as _self.
  • _top: Load the response into the top-level browsing context (that is, the browsing context that is an ancestor of the current one, and has no parent). If there is no parent, this option behaves the same way as _self.
name
The name of the button, which is submitted with the form data.
type
The type of the button. Possible values are:
  • submit: The button submits the form data to the server. This is the default if the attribute is not specified, or if the attribute is dynamically changed to an empty or invalid value.
  • reset: The button resets all the controls to their initial values.
  • button: The button has no default behavior. It can have client-side scripts associated with the element's events, which are triggered when the events occur.
value
The initial value of the button.

Examples

This creates a new button input with the label 'Click me'. 

<input type="button" value="Click me">

Specifications

Specification Status
WHATWG HTML Living Standard
The definition of '<button>' in that specification.
Living Standard
HTML5
The definition of '<button>' in that specification.
Recommendation
HTML 4.01 Specification
The definition of '<button>' in that specification.
Recommendation

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 1.0 1.0 (1.7 or earlier) (Yes) (Yes) (Yes)
formenctype attribute 9.0 4.0 (2.0) 10 10.6 ?
formmethod attribute 9.0 4.0 (2.0) 10 ? ?
autofocus attribute 9.0 4.0 (2.0) 10 9.6 5.0
formaction attribute 9.0 4.0 (2.0) 10 ? ?
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support (Yes) 1.0 (1.0) (Yes) (Yes) (Yes)
formenctype attribute ? 4.0 (2.0) ? ? ?
formmethod attribute ? 4.0 (2.0) ? ? ?
formaction attribute ? 4.0 (2.0) ? ? ?

 

See also

 

  • The generic <input> element and the interface used to manipulate it, HTMLInputElement
  • The HTML5 replacement for <input type="button">, the <button> element.

Etiquetas y colaboradores del documento

 Colaboradores en esta página: LexAenima
 Última actualización por: LexAenima,