Common input types in one form
<input type="text">
<input type="email" required>
<input type="number" min max>
<input type="radio" name>
<input type="checkbox">
<input type="file">
<input type="hidden">type selects the control kind. The default type is text. This is one form, not six separate pages.
| Attribute | Description |
|---|---|
type | The control kind. The default is text. Invalid values are also treated as text. |
name | The submitted key. Nameless controls are not successful. |
value | Initial value, or the submitted value for checkbox, radio, and some button types. |
checked | For checkbox and radio, the initial on state. Only the checked radio in a name group is successful. |
accept | For file inputs, a hint for allowed file types. It is not a security check. |
min, max, step, maxlength | Constraints for types that support them. They affect client validation and some steppers, not server enforcement. |
- accept and required are hints or client checks. They do not inspect or upload a user file in this documentation, and they do not replace server-side checks.
<form>
<p>
<label for="title">Title</label>
<input id="title" name="title" type="text" maxlength="80">
</p>
<p>
<label for="email">Email</label>
<input id="email" name="email" type="email" required>
</p>
<p>
<label for="qty">Quantity</label>
<input id="qty" name="qty" type="number" min="1" max="9" value="1">
</p>
<fieldset>
<legend>Format</legend>
<label><input type="radio" name="format" value="html" checked> HTML</label>
<label><input type="radio" name="format" value="text"> Plain text</label>
</fieldset>
<p>
<label><input type="checkbox" name="draft" value="1"> Save as draft</label>
</p>
<p>
<label for="photo">Photo</label>
<input id="photo" name="photo" type="file" accept="image/png,image/jpeg">
</p>
<input type="hidden" name="step" value="practice">
<button type="submit">Check locally</button>
</form>What this markup means
The form demonstrates textual, numeric, radio, checkbox, file, and hidden inputs together. type="email" plus required is only a client constraint. The file input does not upload a file from this page. There is no third-party action.
Related: Tag catalog: <input>, <form>, <button>, <label>, <select>, <textarea>