Search code examples
htmlbuttonsemantics

Does a <button> TYPE have to be defined?


When using the button tag, does the type attribute have to be defined, or is it semantic to just have?

<button>Click Me</button>

Solution

  • No, you don't have to specify it, it defaults to the value submit.

    See the HTML 4.x specification:

    type        (button|submit|reset) submit -- for use as form button --
                                      ^^^^^^ default value
    

    Compare with the action attribute for forms where it says #REQUIRED instead of giving a default value.

    action      %URI;          #REQUIRED -- server-side form handler --