The type attribute

The value of type dramatically changes an element's behavior — especially for input (text, email, checkbox...), button (submit/button/reset), and script (module/text/javascript).

Applies to

input, button, script, ol

Values

Depends on the element: for input — text, email, password, number, checkbox, radio, file, date, etc.; for button — submit, button, reset; for script — "module" or plain.

Example

<input type="email" name="email">
<button type="button">Just an action</button>

Edge cases

  • A button inside a form with no explicit type defaults to type="submit" — a common cause of unexpected form submissions.
  • An input with no type defaults to behaving like type="text".

Related tools