Attributes

Introduction

The input element defines form controls. This sheet covers attributes, input types, and examples for dates, numbers, and text.

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

  • email
  • 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

TypeExample
type='date'
type='time'

See: Date state (type=date)

Datetime

TypeExample
type='datetime-local'

datetime was removed from the HTML spec; use datetime-local and a separate time zone control.

See: Local Date and Time state (type=datetime-local)

Numbers

TypeExample
type='number'
type='range'

See: Number state (type=number)

Text

TypeExample
type='text'
type='password'
type='search'
type='tel'

See: Text state (type=text)

Also see

0 Comments for this cheatsheet. Write yours!