Note GET appends data to the URL (visible, cacheable, bookmarkable). POST sends data in the request body (for sensitive data and large payloads). Omitting method defaults to GET.
Note Different type values trigger different mobile keyboards and built-in validation. For example, type="email" shows an @ key on mobile and validates email format.
text inputinput fieldtext boxemail inputpassword field
Note Number inputs show spinners on desktop and numeric keyboards on mobile. The step attribute controls increment size. Use step="any" for decimal values.
number inputsliderrange inputquantity fieldnumeric input
Note Date picker appearance varies significantly across browsers and platforms. The value format is always ISO 8601 (YYYY-MM-DD) regardless of display format. Use min and max to constrain the selectable range.
date pickerdate inputtime inputdatetimecalendar input
Note Radio buttons with the same name attribute form an exclusive group where only one can be selected. Checkboxes allow multiple selections. Wrap each in a label for a clickable hit area.
<labelfor="country">Country:</label><selectid="country"name="country"><optionvalue="">Select a country</option><optgrouplabel="North America"><optionvalue="us">United States</option><optionvalue="ca">Canada</option><optionvalue="mx">Mexico</option></optgroup><optgrouplabel="Europe"><optionvalue="uk">United Kingdom</option><optionvalue="de">Germany</option></optgroup></select>
Note Use optgroup to categorize options. Add an empty first option as a placeholder. For multi-selection, add the multiple attribute, but consider checkboxes instead since multi-select is not intuitive for many users.
dropdownselect menuselect boxoption listpick list
Textarea
Syntax
<textareaname="field"rows="n"cols="n"></textarea>
Example
<labelfor="message">Your Message:</label><textareaid="message"name="message"rows="5"cols="40"placeholder="Type your message here..."maxlength="500"></textarea>
Note Unlike input, the textarea value goes between the opening and closing tags, not in a value attribute. Use the CSS resize property to control whether users can resize it.
<labelfor="fullname">Full Name</label><inputtype="text"id="fullname"name="fullname"><!-- Or wrapping approach --><label>
Phone Number
<inputtype="tel"name="phone"></label>
Note Every form input must have a label for accessibility. The for attribute must match the input's id. Alternatively, wrap the input inside the label element to create an implicit association.
Note Unlike select, datalist allows free-text entry in addition to the suggestions. The user is not forced to pick from the list. Browser rendering of suggestions varies.
<inputtype="text"name="zipcode"requiredpattern="[0-9]{5}"title="Five digit zip code"><inputtype="password"name="password"requiredminlength="8"maxlength="128"><inputtype="number"name="age"min="18"max="120">
Note Built-in validation runs on form submission and is bypassed by adding formnovalidate to the submit button or novalidate to the form. The title attribute provides a hint message shown when the pattern fails.