EMZETT.
Login

Button

In short: A button is a control that triggers an action on a click or tap. In HTML you write <button>.

In more detail: The button is the most common element of an interface. It should be clearly labelled, reachable by keyboard and understandable for screen readers.

In detail

<button type="button" onclick="save()">Save</button>
<form><button type="submit">Send</button></form>
  • type: button (click only), submit (sends the form), reset. Without type, submit applies inside forms.
  • disabled: switches the button off.
  • Link or button: a link (<a>) navigates to an address, a button performs an action.
  • Accessibility: use real <button> elements, not <div onclick>. Visible focus, sufficient size (at least about 44 px), meaningful text.
  • Design: highlight the main action, make secondary actions subtler.
  • Law: for online orders the button must be unambiguous, see Cancellation button (§ 312k BGB).

See also: Events, Function