</>
ValidateHTML

Missing Button Type Attribute

A <button> element without a type attribute defaults to type="submit". This means any button inside a form will submit the form when clicked, even if that wasn't intended. This is a common source of bugs where clicking a 'Cancel' or 'Clear' button accidentally submits the form.

Why It Matters

Unexpected form submissions frustrate users and can cause data loss. For accessibility, screen readers announce the button type, and a mislabeled button type gives incorrect information about what the button does. It's flagged by most HTML validators and accessibility auditing tools.

Code Examples

Inaccessible
<form>
  <input type="text" name="search">
  <!-- This button submits the form! -->
  <button>Clear</button>
  <button>Submit</button>
</form>
Accessible
<form>
  <input type="text" name="search">
  <button type="button">Clear</button>
  <button type="submit">Submit</button>
  <button type="reset">Reset</button>
</form>

How to Fix

  • 1Always add an explicit type attribute to every <button> element.
  • 2Use type="submit" for buttons that should submit a form.
  • 3Use type="button" for buttons that trigger JavaScript actions without submitting.
  • 4Use type="reset" only for buttons that should reset form fields to their default values.

Check Your Accessibility Now

Our accessibility checker detects this issue automatically.

Open Accessibility Checker
Recommended

Hostinger Fast & Affordable Web Hosting

Deploy accessible, validated code on reliable hosting.

Get 80% Off Hosting →

Related Accessibility Errors

View all accessibility errors