HTML <button> tag

Updated: 10/11/2017 by Computer Hope

HTML button tagWhen writing in HTML, the <button> tag is an inline element used to create a clickable button. It is useful when you want to allow users to submit information or perform a search on your website. The following sections contain information about this tag, including an example of it in use, as well as related attributes and browser compatibility.

Note: The <button> tag belongs to a group of tags called form elements.

Example code

<form action="">
<input name="q" type="text" size="23">
<button type="Submit">Search</button>

Example result

Clicking the Search button will search Computer Hope for whatever text you enter into the adjacent box.


Within an HTML tag, an attribute dictates certain aspects of an HTML element. Attributes are made up of a name and value pair; all tags support standard attributes. The following table shows all of the current unique HTML attributes for the <button> tag, as well as a description of each.

Attribute Description
autofocus Designates that the button will be focused when the page loads
disabled Disables the button
form Designates which form(s) belong to the button
formaction Designates where form-data is sent when the button is clicked
formenctype Designates the encoding for form-data before sending it to a server
formmethod Designates which HTTP method to use when sending form-data
formnovalidate Designates that form-data should not be validated when it is submitted
formtarget Designates where to display submitted form data
name Designates a name for the button
type Designates the button's type
value Designates an initial value for the button


Internet Explorer Firefox Safari Opera Chrome
All versions All versions All version All versions All versions

Additional form elements

Browser, Compatibility, Encode, Form, HTTP, Server, Web design terms