
- HTML Home
- HTML Roadmap
- HTML Introduction
- HTML History & Evolution
- HTML Editors
- HTML Basic Tags
- HTML Elements
- HTML Attributes
- HTML Headings
- HTML Paragraphs
- HTML Fonts
- HTML Blocks
- HTML Style Sheet
- HTML Formatting
- HTML Quotations
- HTML - Comments
- HTML - Colors
- HTML - Images
- HTML - Image Map
- HTML - Frames
- HTML - Iframes
- HTML - Phrase Elements
- HTML - Code Elements
- HTML - Meta Tags
- HTML - Classes
- HTML - IDs
- HTML - Backgrounds
- HTML Tables
- HTML - Tables
- HTML - Table Headers & Captions
- HTML - Table Styling
- HTML - Table Colgroup
- HTML - Nested Tables
- HTML Lists
- HTML - Lists
- HTML - Unordered Lists
- HTML - Ordered Lists
- HTML - Definition Lists
- HTML Links
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML Color Names & Values
- HTML - Color Names
- HTML - RGB & RGBA Colors
- HTML - HEX Colors
- HTML - HSL & HSLA Colors
- HTML - HSL Color Picker
- HTML Forms
- HTML - Forms
- HTML - Form Attributes
- HTML - Form Control
- HTML - Input Attributes
- HTML Media
- HTML - Video Element
- HTML - Audio Element
- HTML - Embed Multimedia
- HTML Header
- HTML - Head Element
- HTML - Adding Favicon
- HTML - Javascript
- HTML Layouts
- HTML - Layouts
- HTML - Layout Elements
- HTML - Layout using CSS
- HTML - Responsiveness
- HTML - Symbols
- HTML - Emojis
- HTML - Style Guide
- HTML Graphics
- HTML - SVG
- HTML - Canvas
- HTML APIs
- HTML - Geolocation API
- HTML - Drag & Drop API
- HTML - Web Workers API
- HTML - WebSocket
- HTML - Web Storage
- HTML - Server Sent Events
- HTML Miscellaneous
- HTML - Document Object Model (DOM)
- HTML - MathML
- HTML - Microdata
- HTML - IndexedDB
- HTML - Web Messaging
- HTML - Web CORS
- HTML - Web RTC
- HTML Demo
- HTML - Audio Player
- HTML - Video Player
- HTML - Web slide Desk
- HTML Tools
- HTML - Velocity Draw
- HTML - QR Code
- HTML - Modernizer
- HTML - Validation
- HTML - Color Picker
- HTML References
- HTML - Cheat Sheet
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Character Entities
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
- HTML Resources
- HTML - Quick Guide
- HTML - Useful Resources
- HTML - Color Code Builder
- HTML - Online Editor
HTML - <button> Tag
Introduction to <button> Tag
The HTML <button> tag is a interactive element that is used to create a clickable buttons on the webpage. It allows to trigger various actions such as submitting a form, executing JavaScript functions. The <button> tag can contain text, images or any other HTML content.
HTML buttons are often styled by using the CSS to improve their appreance and provide visual feedback to the user. By default, the <button> type is submit, which submits the form data. We can also explicitly set the type attribute to button to prevent submission or reset.
Syntax
Following is the syntax of HTML <button> tag −.
<button>button name</button>
Attributes
HTML button tag supports Global and Event attributes of HTML. And some specific attributes as well which are listed bellow.
Attribute | Value | Description |
---|---|---|
autofocus | autofocus | A button getting focus when the page loads |
disabled | disabled | Disable a button |
form | form_id | One or more forms the button belongs to |
formaction | URL | For type="submit". Where to send the form-data when a form is submitted. |
formenctype | application/x-www-form-urlencoded multipart/form-data text/plain |
For type="submit". How form-data should be encoded before sending it to a server. |
formmethod | get post |
For type="submit". How to send the form-data " |
formnovalidate | formnovalidate | For type="submit". The form-data should not be validated on submission. |
formtarget | _blank _self _parent _top framename |
For type="submit". Where to display the response after submitting the form. |
name | name | Specifies a name for the button |
type | button reset submit |
Specifies the type of button |
value | text | Specifies an initial value for the button |
Example : Basic Button
Let's look at the following example, where we are going to consider the basic usage of the <button> tag.
<!DOCTYPE html> <html lang="en"> <head> <title>HTML Button</title> </head> <body> <h1>HTML button</h1> <!-- HTML Button --> <button>click</button> </body> </html>
Example : Disabled Button
Consider the following example, where we are going to use the disabled attribute along with the <button> tag.
<!DOCTYPE html> <html lang="en"> <head> <title>HTML Button</title> </head> <body> <h1>HTML button Tag</h1> <strong>Normal HTML Button:</strong> <!-- HTML Button --> <button>Submit</button> <br><br> <strong>Disable HTML Button:</strong> <!-- HTML Button --> <button disabled>Submit</button> </body> </html>
Example : Applying CSS
In the following example, we are going to use the <button> tag and applying the CSS.
<!DOCTYPE html> <html lang="en"> <head> <title>HTML Button</title> <style> button { margin: 10px; padding: 10px; border-radius: 5px; background-color: green; } </style> </head> <body> <h1>HTML button Tag</h1> <!-- HTML Button --> <button>ClickMe!</button> </body> </html>
Example : Button with Image
Following is the example, where we are going to add the image to the button.
<!DOCTYPE html> <html> <body style="text-align:center"> <button> <img src="https://www.tutorialspoint.com/cg/images/logo.png" alt="LOGO" style="width: 200px; height: 20px;"> </button> </body> </html>
Supported Browsers
Tag | ![]() |
![]() |
![]() |
![]() |
![]() |
---|---|---|---|---|---|
button | Yes | Yes | Yes | Yes | Yes |