button

FilterElements

<button> ... </button>

Used as part of a form, defines a “button” that functions similarly to buttons created with the input element but allows for richer rendering possibilities. Buttons can contain content such as text and images (but not image maps).

Start/End Tags

Required/Required

Specifications

  • HTML 4.01
  • HTML5

autofocus

Values: None in HTML. autofocus="autofocus" in XHTML.
HTML5 only. Indicates the control should have focus (be highlighted and ready for user input) when the document loads.

disabled

Values: None in HTML. disabled="disabled" in XHTML.
Disables the control for user input. It can be altered only via a script. Browsers may display disabled controls differently (grayed out, for example), which could be useful for dimming certain controls until required info is supplied.

form=

Values: id of the form owner
HTML5 only. Explicitly associates the input control with its associated form (its form owner). With this method, the input control does not need to be a child of the form element that applies to it.

formaction=

Values: URL
HTML5 only. Specifies the application that will process the form. It is used only with a submit button (input type="submit") and has the same function as the action attribute for the form element.

formenctype=

Values: content type
HTML5 only. Specifies how the form values are encoded with the post method type. It is used only with a submit button (input type="submit") and has the same function as the enctype attribute for the form element. The default is Internet Media Type (application/x-www-form-urlencoded). The value multipart/form-data should be used in combination with the file input type.

formmethod=

Values: get | post | put | delete
HTML5 only. Specifies which HTTP method will be used to submit the form data. It is used only with a submit button (input type="submit") and has the same function as the method attribute for the form element. The put and delete values are new in HTML5.

formnovalidate=

Values: URL
HTML5 only. Indicates that the form is not to be validated during submission. It is used only with a submit button (input type="submit") and has the same function as the novalidate attribute for the form element (new in HTML5).

formtarget=

Values: name
HTML5 only. Specifies the target window for the form results. It is used only with a submit button (input type="submit") and has the same function as the target attribute for the form element.

name=

Values: text
Required. Assigns the control name for the element.

type=

Values: submit | reset | button
Identifies the type of button: submit button (the default type), reset button, or custom button (used with JavaScript), respectively.

value=

Values: text
Assigns the value to the button control. The behavior of the button is determined by the type attribute.
<button type="reset" name="reset"><img src="x.gif" alt=""> Try again.</button>

Rendered Example

This example is shown with default styles only.