<div>
<input type="radio" id="1" name="same" value="1" checked>
<label for="1"></label>
</div>
<div>
<input type="radio" id="2" name="same" value="2">
<label for="2">2</label>
</div>
<div>
<input type="radio" id="3" name="same" value="3">
<label for="3">3</label>
</div>
Choose One:
Dogs Cats
Use the same value for name attributes to group radio buttons. Can only select one.
<label for="select">Choose an Option:</label>
<select name="select" id="select">
<option value="">--Please choose an option--</option>
<option value="chocolate">chocolate</option>
<option value="vanilla">vanilla</option>
<option value="strawberry">strawberry</option>
</select>
Represents a control that provides a menu of options.
Attributes:
multiple - able select mulitple by highlighting
size="2, 3, ..." - number of options displayed
selected - use on an option, predefined selected choice
<textarea rols="" cols=""></textarea>
Use this CSS to make it non-resizable:
textarea {
resize: none;
}
To add a multiline text input field.
<form oninput="result.value=parseInt(a.value)+parseInt(b.value)">
<input type="range" id="b" name="b" value="50" /> +
<input type="number" id="a" name="a" value="10" /> =
<output name="result" for="a b">60
</form>
Inject the results of a calculation or the outcome of a user action.
<div>
<input type="checkbox" id="1" name="">
<label for="1">1</label>
</div>
<div>
<input type="checkbox" id="2" name="">
<label for="2">2</label>
</div>
Choose Multiple:
Use the same value for name attributes to group checkboxes. Can select multiple.
<input list="datalist" id="" name="">
<datalist id="datalist">
<option value="1">
<option value="2">
<option value="3">
<option value="4">
<option value="5">
</datalist>
Choose Favorite Hero:
Defines a list of predefined option values for an input. Match a list attribute to id.
<label for="cars">Choose a car:</label>
<select name="cars" id="cars">
<optgroup label="Swedish Cars">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
</optgroup>
<optgroup label="German Cars">
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</optgroup>
</select>
Defines a group of related options in a drop-down list.
<button type="submit">Submit</button> // submit form data to a source (server)
Reset and Button:
<button type="reset">Clear</button> // clears all form data
<button type="button"></button> // no default behavior, use JavaScript
To submit a form to a source.
Input Restrictions and Attributes:
name="" - submitted with the form as (name:value) pair
value="" - value to be used
checked - predefined selected, boolean as well
disabled - disable input
max="" - maximum value
min="" - minimum value
maxlength="" - maximum amount of characters
minlength="" - minimum amount of characters
pattern="{regex}" - provide a regex to control input values
readonly - makes input not editable
required - input needs a value
size="" - defines width and height of input
step="" - set stepping interval
multiple - can accept one or more values
placeholder="" - add input text
autofocus - should be focused on page load
autocomplete="" - automated assistance
Input Form Attributes:
form="" - connect input to a form, must match id with forms
formaction="" - specifies the URL of the form that will process the input, overrides action attribute of form
formenctype="" - specifies how form-data should be encoded before sending it to a server
formmethod="post" - defines HTTP method, overrides method attribute of form
formtarget="_blank" - specifies a name or keyword where to display the response
formnovalidate="formnovalidate" - should not be validated when submitted, overrides novalidate (submit)
Attributes to use for inputs.
<input type="radio">
<input type="button" value="submit">
<input type="checkbox">
<input type="color">
<input type="date">
<input type="datetime-local">
<input type="email">
<input type="file”>
<input type="hidden">
<input type="image">
<input type="month">
<input type="number">
<input type="password">
<input type="range">
<input type="reset">
<input type="search">
<input type="submit">
<input type="tel">
<input type="text”>
<input type="time">
<input type="url">
<input type="week">
All the different types of inputs.
<label for="progress">File progress:</label>
<progress id="progress" max="100" value="70"> 70% </progress>
Used to add a progress bar. Use Javascript to change the value using other values.