Why add the type attribute in the <button> element

In HTML <button> tag defines a button.

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

Within the button elements, you can place the content, such as text or images. This is the difference between this element and buttons created with the input element.

<input type="button" value="Click Me!">

Since the definition of a button a button, so why to add type attributes?

button tag type attribute has the value 3

w3school is written like this:

Always provisions for the button type attribute. Internet Explorer is the default type of "button", while other browsers default values ​​(including the W3C specification) is "submit".

 

Therefore, when using the button labels clearly set its type attribute, it can be avoided because the browser's default property values ​​lead to different types of buttons appear different.

Guess you like

Origin www.cnblogs.com/yuer20180726/p/11028954.html