- button
- checkbox
- file*
- hidden
- image
- password
- radio
- reset
- submit
- text
This presentation is an HTML5 website
Press → key to advance.
Zoom in/out: Ctrl or Command + +/-
Estelle Weyl
New Elements
Old Elements
<p>
<label for="inputID">Label: </label>
<input id="inputID" name="inputName" type="text" />
</p>
The value of the for attribute should match the value of the input's id attribute
Click on the label to activate the form element:
<label for="name">Name: </label> <input id="name" name="inputName" placeholder="placeholder text" pattern="\w{6,9}" required autofocus type="text"/>
<label for="inputID">Label: </label> <input id="inputID" name="inputName" placeholder="placeholder text" pattern="\w{6,9}" required autofocus type="text"/>
Use JS & the placeholder contents for non-supporting browsers
$("input[placeholder]").each(function(){ if($(this).val()==""){ $(this).val($(this).attr("placeholder")); $(this).focus(function(){ if($(this).val()==$(this).attr("placeholder")) $(this).val(""); }); $(this).blur(function(){ if($(this).val()==""){ $(this).val($(this).attr("placeholder")); } }); } });
<label for="inputID">Label: </label> <input id="inputID" name="inputName" placeholder="placeholder text" pattern="\w{6,9}" required autofocus type="text"/>
<label for="inputID">Label: </label> <input id="inputID" name="inputName" placeholder="placeholder text" pattern="\w{6,9}" required autofocus type="text"/>
input[required] {border: 1px dashed #f00;} or input:required {border: 1px dashed #f00;}
<label for="inputID">Label: </label> <input id="inputID" name="inputName" placeholder="placeholder text" pattern="\w{6,9}" required autofocus type="text"/>
only one element can have the autofocus attribute
$('[autofocus]').first().focus();
<label for="inputID">Label: </label> <input id="inputID" name="inputName" placeholder="placeholder text" pattern="\w{6,9}" required autofocus type="text" />
<input name="color" type="color" />
<input id="color" name="color" type="color" placeholder="#FFFFFF" pattern="#(?:[0-9A-Fa-f]{6}|[0-9A-Fa-f]{3})" required />
<input name="website" type="url" />
Opera, Safari & Chrome.
Any prefix (http:// or even g:// accepted)<input id="website" name="url" type="url" placeholder="http://www.domain.com" pattern="(http|https|ftp)\:\/\/[a-zA-Z0-9\-\.\/]*"/>
different dynamic keyboards displayed based on input type.
<input name="telephone" type="tel" />
Relevant only in mobile. Keyboard changes, but no validation.
<input id="phone" name="phone" type="tel" placeholder="415-555-1212" pattern="\d{3}\-\d{3}\-\d{4}"/>
<input name="eaddress" type="email" />
Keyboard changes & validation!
<input id="email" name="email" type="email" placeholder="you@domain.com" multiple />
<input name="n" type="number"/>
<input id="nickels" type="number" placeholder="0, 5, 10 …" pattern="[0-9]*[05]" min="0" max="1000" step="5" />
<input id="range" name="range" type="range" placeholder="0 to 10" pattern="[0-9]|10" min="0" max="10" step="1"/>Current Value:
<input id="range" name="range" type="range" min="0" max="100" step="5"/>Current Value:
Supported by Opera, Safari & Chrome
<input id="search" name="search" type="search" placeholder="search terms"/>
UI supported in Safari and Chrome
Warning: if you stylize the input, the 'delete' may not showdate | 2010-11-03 | |
datetime | 2010-11-03 19:00 | |
datetime-local | 2010-11-03 19:00 | |
month | 2010-11 | |
time | 19:00 | |
week | 2010-W44 |
Works in Safari, Chrome and really, really well in Opera.
<input id="DOB" name="DOB" type="date" placeholder="YYYY-MM-DD" pattern="\d{4}\-\d{2}\-\d{2}" min="1900-01-01" />
<input name="time" id="time" type="time" min="09:00" max="17:00" step="900" placeholder="12:00" required />
Supported in Chrome, Safari and Opera
<label for="url">Web Address: </label> <input id="url" type="url" name="url1" placeholder="www.domain.com" required list="datalist1" /> <label for="url2">Web Address2: </label> <input id="url2" type="url" name="url2" placeholder="www.domain.com" list="datalist1" /> <datalist id="datalist1"> <option value="http://www.standardista.com" /> <option value="http://www.apress.com" /> <option value="http://www.evotech.net" /> </datalist>
<meter value="90" min="0" max="100">90%</meter>
Gas tank:
<progress>loading...</progress>
Please wait:
<progress value="75" max="100">75% complete</progress>
Download is:
<output>
All these are currently chrome only