The HTML5 <button> tag is an element in HTML5 which defines a clickable button. The HTML5 <button> tag is used by inserting a button element on the document. This can be clicked to perform a defined action. Inside the HTML5 <button> element is where you can put content like simple text or even images. That is what defines the main difference between this element and the other buttons created with the use of the <input> command.
The HTML5 <button> tag is needed when it comes to creating visual buttons on the document. Adding the attributes is important for it to be set. There are also differences in HTML4.01 and HTML5 since there are new attributes that can be utilized. Here are the attributes for the HTML5 <button> element:
|
Attribute
|
Value
|
Description
|
|
autofocus (NEW)
|
autofocus
|
Autofocus on the button when page loads
|
|
Disabled
|
disabled
|
Disable button on load
|
|
form (NEW)
|
form_id
|
Specifies form button belongs to
|
|
formaction
(New)
|
URL
|
Identifies location where to send data type="submit"
|
|
formenctype
(NEW)
|
application/x-www-form-urlencoded
multipart/form-data
text/plain
|
Identifies the way data should be encoded
type="submit"
|
|
formmethod
(NEW)
|
get
post
|
Identifies HTTP method to use for data submission.
Only for type="submit"
|
|
formnovalidate (NEW)
|
formnovalidate
|
Identifies data that should be validated. Only for
type="submit"
|
|
formtarget
|
_blank
_self
_parent
_top
framename
|
Set response location after data is submitted. Only
for type="submit"
|
|
name
|
name
|
Identifies a name for the button
|
|
type
|
button
reset
submit
|
Identifies the type of button
|
|
value
|
text
|
Identifies an initial value for the button
|
The HTML5 <button> tag is supported in all major browsers such as , Internet Explorer, Firefox, Opera, Google Chrome, and Safari.
The HTML5 <button> tag is compatible with the Global Attributes in HTML5 and the Event Attributes in HTML5 as well.