HTML Buttons Example

HTML Buttons :

There are two basic ways of creating an HTML button; with the <button> tag, and with the <input> tag.

This page provides code for both methods. The <button> element is used to create an HTML button. Any text appearing between the opening and closing tags will appear as text on the button.

No action takes place by default when a button is clicked. Actions must be added to buttons using JavaScript or by associating the button with a form.

The <button> tag is used to create clickable buttons on the web page. The difference between these elements and buttons created with the <input> tag is that you can place the content (images or text) inside the <button>.

Button Example :



Attributes of HTML Button Tag


AttributeDescription
autofocusIt specifies that a button should automatically get focus while the loading of the page.
disabledIt specifies that a button shuld be disabled.
formIt specifies one or more forms that the button belongs to.
formactionIt is used for submit type. It specifies where to send the form data when form is submitted.
formmethodIt specifies how to send form-data.
formenctypeIt specifies how form-data should be encoded before sending it to server.
formnovalidateIt specifies that the form data should not be validated on submission.
formtargetIt specifies that where to display the response after submitting the form.
nameIt specifies the name of the button.
typeIt specifies the type of the button.
valueIt specifies the value of the button.