Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

HTML5 <button> tag


May 03, 2021 HTML5


Table of contents


Html5 is used to define a button, and the content within the label is the content of the button you want to use.

The following code marks a button:

<button type="button">点我!</button>
Try it out . . .

Browser support

HTML5 <button> tag HTML5 <button> tag HTML5 <button> tag HTML5 <button> tag HTML5 <button> tag

All major browsers support the hashtag.


Label definition and instructions for use

The label defines a button.

Inside the element, you can place content, such as text or images. This is the difference between the element and the button created with the .lt;input.gt; element.

Tip: Always specify the type property for the element. Different browsers use different default values for the type property of the element.


Tips and comments

Note: Different browsers may submit different button values if the element is used in HTML forms. Please create a button in an HTML form using slt;input.


The difference between HTML 4.01 and HTML5

New properties in HTML5: autofocus, form, formaction, formenctype, formmethod, formnovalidate, and formtarget.


Property

New: The new property in HTML5.

Property Value Describe
autofocus New autofocus It is stipulated that the button should automatically get focus when the page loads.
disabled disabled The rule is that the button should be disabled.
form New form_id The specified button belongs to one or more forms.
formaction New Url Specify where form data is sent when a form is submitted. O verrides the action property of the form element. This property is used in conjunction with type "submit".
formenctype New application/x-www-form-urlencoded
multipart/form-data
text/plain
Specify how form data is encoded before it is sent to the server. O verrides the enctype property of the form element. This property is used in conjunction with type "submit".
formmethod New get
post
Specifies the HTTP method used to send form data. O verrides the method property of the form element. This property is used in conjunction with type "submit".
formnovalidate New formnovalidate If you use this property, the form is not validated when it is submitted. O verrides the novalidate property of the form element. This property is used in conjunction with type "submit".
formtarget New _blank
_self
_parent
_top
framename
Specify where to open the action URL. O verrides the target property of the form element. This property is used in conjunction with type "submit".
name name Specify the name of the button.
type button
reset
submit
Specify the type of button.
value text Specifies the initial value of the button. Can be modified by the script.


Global properties

The label supports the global properties of HTML.


The event property

The tag supports the event properties of HTML.


Note: The elements are easier to style than the elements. You can add inline HTML content (e.g., .lt;em>?strong> or even .lt;img>) and use :after and :before pseudo-elements for complex renderings, while the only text value properties are .

Related articles

HTML DOM Reference Manual: Button Object