HTML Tutorial

List Of Form Elements

Names Examples
<input type="text">
Text is the default value for type.
<input type="password">
<input type="reset">
<input type="submit">
<textarea>
<input type="hidden"> Data is hidden from user.
<input type="radio">
<input type="radio" checked="checked">
<input type="checkbox">
<input type="checkbox" checked="checked">
<select> and <option>
<select name="select1">
 <option value="1">1</option>
 <option value="2">2</option>
 <option value="3">3</option>
</select>
<button name="button1">This is a button</button>
Buttons can't work with PHP without Javascript.
<input type="button" name="button1" value="This is a input">
Used with Javascript.
<input type="file">
<input type="image" src="../../images/tree_cat_thumb.jpg">
<input type="color">
<input type="range">
<input type="datetime-local">
<input type="time">
<input type="date">
<input type="week">
<input type="month">
<input type="email" placeholder="email">
<input type="number" placeholder="numbers only">
<input type="tel" placeholder="Enter Phone number">
<input type="url">
<input type="search">
<label> Makes a label for a form element.
<fieldset></fieldset> Displays a box around of a group of form elements.
<legend> </legend> Displays a legend for <fieldset>

Form Element Attributes

Some attributes that form elements may have include:

name
Name of element and the variable submitted. Required except when input type="submit"
accept
Filter what file types the user can pick from the file input dialog box. Only for input type="file".
accesskey
Assignes a character to a element that moves the focus to that element whener presses a key and the Alt key.
autocomplete
Determines whether an input element should have autocomplete enabled. Values are "on" or "off".
checked
Sets radio buttons and checkboxs to checked state
disabled
The element is dimmed to let the user know that it is disabled.
<input type="text" disabled value="disabled" />
maxlength
Maximum number of characters that may be entered
multiple
Allows the user can enter more than one option on a select menu.
required
The form cannot be submitted if this element is not filled.
readonly
Same as disabled but appears normal.
<input type="text" readonly value="readonly" />
placeholder
A short hint displayed in the input field before the user enters a value. Used in text inputs like URL, email, number etc.
pattern
A regular expression that the <input> element's value is checked against on form submission. Used in text inputs like URL, email, number etc.
selected
Sets the focus.
<select>
 <option>1</option>
 <option selected>2</option>
 <option>3</option>
</select>
size
Width of control in pixels except for text and password inputs which a measured by number of characters.
value
Initial value of control