On this page
  1. Forms & Inputs
  2. Contents
  3. Core Form Controls
  4. Grouping & Output Elements

Forms & Inputs

Prev: Text & Lists | Up: elements | Next: Tables & Media
Rel: Form & Validation Attributes, Accessible Forms & Validation, Pseudo-Classes, Forms, Validation & Fetch
Ref: MDN Web Docs — HTML Elements
Tags: #public #web #html #elements #forms


Contents


Core Form Controls

Always associate every control with a <label> via matching for / id (or by wrapping the control) and set type="button" on non-submitting <button> elements inside a <form>.

<form method="post">
  <fieldset>
    <legend>Preferences</legend>

    <label for="display-name">Display Name</label>
    <input id="display-name" name="display_name" type="text" required />

    <label for="plan">Plan</label>
    <select id="plan" name="plan">
      <option value="free">Free</option>
      <option value="pro">Pro</option>
    </select>

    <button type="submit">Save</button>
  </fieldset>
</form>

Grouping & Output Elements

Linked from

Related notes