Skip to content

<button> - The Button Element

Form Control HTML 4.0

The button element creates clickable buttons for user interaction. Unlike <input type="button">, it can contain HTML content like images and text formatting.

Result
<button type="button">Button Text</button>

The button requires an opening and closing tag. Content between the tags becomes the button label.

AttributeDescriptionValues
typeButton behaviorbutton, submit, reset
nameName for form dataString
valueValue sent with form dataString
disabledDisables the buttonBoolean
formAssociates with a form by IDForm element ID
autofocusAuto-focus on page loadBoolean

These override form attributes when the button submits:

AttributeDescriptionValues
formactionOverride form action URLURL
formmethodOverride form methodget, post
formenctypeOverride form encodingapplication/x-www-form-urlencoded, multipart/form-data, text/plain
formnovalidateBypass form validationBoolean
formtargetOverride form target_self, _blank, _parent, _top

Generic button with no default behavior (requires JavaScript):

Result

Submits the parent form (default type):

Result

Resets all form fields to their initial values:

Result
Result
Result

Use the form attribute to associate with a form elsewhere:

Result

Different buttons can submit to different actions:

Result
Result
Result
Result
Result
Result
<!-- Visible text -->
<button type="button">Delete</button>
<!-- Icon with accessible label -->
<button type="button" aria-label="Delete item">
<svg>...</svg>
</button>
<button type="button">Delete Comment</button>
<button type="button">Save Changes</button>
<button type="submit">Submit Application</button>

Never remove focus outlines without providing an alternative:

Result
Result
Result
<button type="submit">
<strong>Submit</strong> Form
</button>

Advantages: Can contain HTML (images, icons, formatting), more flexible for styling, better semantics, and easier to work with.

BrowserVersionNotes
Chrome1+Full support
Firefox1+Full support
Safari1+Full support
Edge12+Full support
IE4+Full support (some CSS limitations in IE6-8)

The <button> element has been supported since HTML 4.0 and works in all modern browsers.