asp.net.ph

Skip Navigation LinksHome > Abakada: Back to Basics > Language References > HTML Elements > BUTTON Element

<button> Element


Represents a command button.HTML 4, 4.01, 5

HTML Syntax

NOTE: Both start and end tags are required.

Remarks

The <button> element creates buttons which function like buttons created with the <input> element, but offer richer rendering possibilities.

The button element may have content that is displayed as a label for the button.

<button>Click Me</button>

which would render on web page as

The type attribute specifies the visual appearance and default behavior of the button.

Though button can contain images, it is not valid to associate an image map with an <img> that appears as the contents of a button element.

Conforming browsers typically render button with relief and an up/down motion when clicked.

When the button object is submitted in a form, user agents submit the value, if it exists.

Attributes

The <button> element supports the following attributes, in addition to global attributes common to all HTML elements.

AttributeValueDescription
autofocusautofocusSpecifies that a button should automatically get focus when the page loads
disableddisabledSpecifies that a button should be disabled
formform_idSpecifies which form the button belongs to
formactionURLSpecifies where to send the form-data when a form is submitted. Only for type="submit"
formenctypeapplication/x-www-form-urlencoded, multipart/form-data, text/plainSpecifies how form-data should be encoded before sending it to a server. Only for type="submit"
formmethodget, postSpecifies how to send the form-data (which HTTP method to use). Only for type="submit"
formnovalidateformnovalidateSpecifies that the form-data should not be validated on submission. Only for type="submit"
formtarget_blank, _self, _parent, _top, framenameSpecifies where to display the response after submitting the form. Only for type="submit"
namenameSpecifies a name for the button
popovertargetelement_idSpecifies a which popover element to invoke
popovertargetactionhide, show, toggleSpecifies what happens to the popover element when the button is clicked
typebutton, reset, submitSpecifies the type of button
valuetextSpecifies an initial value for the button

Example

The following example shows submit and reset buttons done with button instead of input.

First name:
Last name:
email:
Male Female
 

Below is the HTML fragment for the sample above.

<form>
<table>
...
<tr>
<td><button type="submit"
   style="background:#036;color:gold;font:bold">
   Send</button></td>
<td><button type="reset"
   style="background:#800;color:gold;font:bold">
   Reset</button></td></tr>
</table>
</form>

External References

See Also

INPUT



Check out related books at Amazon

© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note