Attributes
Introduction
The input element defines form controls. This sheet covers attributes, input types, and examples for dates, numbers, and text.
- input element (html.spec.whatwg.org)
- input type attribute (html.spec.whatwg.org)
Input
Common attributes
<input ...
disabled
required
checked
Focus
autofocus
Autofill and keyboards
autocomplete='cc-exp' <!-- autofill token -->
autocapitalize='off'
inputmode='numeric' <!-- mobile keyboard -->
pattern='\d*' <!-- validation -->
See: the input element
Input types
Text
- hidden
- password
- tel
- text
- search
- url
Time
- date
- datetime-local
- time
Time (limited or obsolete)
- month
- week
- datetime
Etc
- file
- radio
- checkbox
- color
Buttons
- button
- reset
- submit
- image
Numeric
- number
- range
See: input type attribute
Examples
Dates
| Type | Example |
|---|---|
type='date' | |
type='time' |
Datetime
| Type | Example |
|---|---|
type='datetime-local' |
datetime was removed from the HTML spec; use datetime-local and a separate time zone control.
Numbers
| Type | Example |
|---|---|
type='number' | |
type='range' |
Text
| Type | Example |
|---|---|
type='text' | |
type='password' | |
type='search' | |
type='tel' |
0 Comments for this cheatsheet. Write yours!