W3Schools.com

HTML5 <button> Tag

Example

A clickable button is marked up as follows:

<button type="button">Click Me!</button>

Try it yourself »

Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The <button> tag is supported in all major browsers.


Definition and Usage

The <button> tag defines a clickable button.

Inside a <button> element you can put content, like text or images. This is the difference between this element and buttons created with the <input> element.

Tip: Always specify the type attribute for a <button> element. Different browsers use different default types for the <button> element.


Differences Between HTML 4.01 and HTML5

HTML5 has new attributes: autofocus,form, formaction, formenctype, formmethod, formnovalidate, and formtarget.


Tips and Notes

Note: If you use the <button> element in an HTML form, different browsers may submit different values. Use <input> to create buttons in an HTML form.


Attributes

New : New in HTML5.

Attribute Value Description
autofocusNew autofocus Specifies that a button should automatically get focus when the page loads
disabled disabled Specifies that a button should be disabled
formNew form_id Specifies one or more forms the button belongs to
formactionNew URL Specifies where to send the form-data when a form is submitted. Only for type="submit"
formenctypeNew application/x-www-form-urlencoded
multipart/form-data
text/plain
Specifies how form-data should be encoded before sending it to a server. Only for type="submit"
formmethodNew get
post
Specifies how to send the form-data (which HTTP method to use). Only for type="submit"
formnovalidateNew formnovalidate Specifies that the form-data should not be validated on submission. Only for type="submit"
formtargetNew _blank
_self
_parent
_top
framename
Specifies where to display the response after submitting the form. Only for type="submit"
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

Global Attributes

The <button> tag also supports the Global Attributes in HTML5.


Event Attributes

The <button> tag also supports the Event Attributes in HTML5.


WEB HOSTING
Best Web Hosting
PHP MySQL Hosting
Best Hosting Coupons
UK Reseller Hosting
Cloud Hosting
Top Web Hosting
$7.95/mo SEO Hosting
Premium Website Design
WEB BUILDING
XML Editor - Free Trial!
FREE Website BUILDER
Free Website Templates Free CSS Templates
Make Your Own Website
W3SCHOOLS EXAMS
Get Certified in:
HTML, CSS, JavaScript, XML, PHP, and ASP
W3SCHOOLS BOOKS
New Books:
HTML, CSS
JavaScript, and Ajax
STATISTICS
Browser Statistics
Browser OS
Browser Display
SHARE THIS PAGE