<button value="">
- Attribute of
- Creating A Button With The HTML Button Element: Here's How
- What does
<button value="">
do? - Sets the initial value of the button element.
There has, historically, been some confusion over the exact purpose of the value
attribute on the <button>
element. With most other form elements, the value is sent to the server when the form is submitted. In the pre-HTML5 era, the behavior of value
varied from browser to browser. Additionally, there is no clear way to affect the value
attribute.
According to the current HTML specification, the value of value
should be sent to the server only if the <button>
is used to submit the form. The idea here is that there could be several <button>
elements available for form submission, all with the same name, and the value
of the one used for submission would be sent with the form data.
This is not a recommended practice. There are usually better ways of allowing the user to make a choice when submitting a form (for example, with radio
inputs or a <select>
element), and the historic problems persist in the small percentage of the population with legacy browsers.
This attribute is best omitted.