HTML <button> tag

Updated: 06/30/2020 by Computer Hope
HTML button tag

When writing in HTML (hypertext markup language), 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, and related attributes and browser compatibility.


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

Example of <button> code

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

Example result

Clicking the Search button searches Computer Hope for whatever text you enter into the adjacent box. For example, if you typed "html" and clicked the search button it would open our HTML page.


All HTML tags support standard attributes that define the settings of an HTML element. In addition to the standard settings, the <button> tag has the following unique attributes.

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 (hypertext transfer protocol) 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.


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

Additional form elements

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