Menu

HTML Input Types: All 22 Types of the input Tag

Every type of the HTML <input> tag in one place: text, email, password, number, range, date and time, color, file, hidden and the rest, with what each one validates, the keyboard it opens on phones, and the attributes they share.

This page includes runnable editors - edit, run, and see output instantly.

The input tag and its types

<input> is a form field, and its type attribute decides which kind. The same tag makes a text box, a slider, a date picker or a color picker. Try each field below and press Submit to see what the form sends:

<input> is a void element, so it has no closing tag. Its name is the key the value is sent under, and value is the starting value. A missing or misspelled type gives a plain text field.

All HTML input types

typeWhat it isNotes
textOne line of textThe default
passwordText shown as dotsNot encrypted by itself; send it over HTTPS
emailAn email addressValidates the format; @ key on phone keyboards
urlA web addressMust start with a scheme such as https://
telA phone numberPhone keypad on mobile, no format check
searchA search boxOften shows a clear button
numberA numberSpin buttons, min, max, step
rangeA sliderImprecise by design; the value is a number
dateA dateValue is YYYY-MM-DD
timeA time of dayValue is HH:MM (24-hour)
datetime-localDate and time, no time zoneValue is YYYY-MM-DDTHH:MM
monthA year and monthNot supported in every browser
weekA year and week numberNot supported in every browser
colorA color pickerValue is #rrggbb in lowercase
checkboxAn on/off boxSee HTML checkbox
radioOne choice out of a groupSee HTML radio button
fileA file chooseraccept, multiple
hiddenA value sent but not shownFor IDs and tokens
submitA submit button<button type="submit"> is more flexible
resetA reset buttonRarely a good idea
buttonA button that does nothing by itselfFor JavaScript
imageA submit button drawn as an imageAlso sends the click coordinates

Text types and phone keyboards

email, url, tel, search and text all look like a text box on a desktop. The difference is validation and, on phones, which keyboard opens. The border in this example turns green or red as the browser judges the value:

  • ada@example is a valid email to the browser: it only checks for text, @ and a domain, not that the domain has a dot. Real checking happens on the server.
  • example.com is not a valid url, because it has no scheme. https://example.com is.
  • tel accepts anything. Phone formats differ too much between countries, so there is no built-in check; add a pattern if you need one.
  • inputmode="numeric" asks phones for a digit keyboard without the problems of type="number", which is why it is the right choice for zip codes, one-time codes and card numbers.

number and range

Both take min, max and step. number is for exact values; range is a slider for values where the exact number matters less. A range slider shows no number, so pair it with an <output>:

step defaults to 1 for number, so a price field without step="0.01" rejects 4.99 when the form is submitted. In JavaScript, input.value is always a string; use input.valueAsNumber to get a number.

Dates and times

The date and time types open the browser's own picker. What the reader sees follows their locale (09/24/2026, 24.09.2026), but the value is always the same fixed format:

That fixed format is what the server receives and what JavaScript reads, so you never have to parse "24.09.2026". min and max take the same format. datetime-local has no time zone: if it matters, convert on the server using the reader's zone.

color and file

accept="image/*" limits the file picker to images (and offers the camera on phones); it also takes extensions, like accept=".pdf,.docx". It is only a hint for the picker, so check the file type on the server. multiple allows several files. A real upload also needs method="post" and enctype="multipart/form-data" on the form.

Suggestions with datalist

A <datalist> gives a text field a list of suggestions while still allowing any value. Connect them with the list attribute:

Type "ja" in the field to see the matching suggestions. Unlike a select, the reader can type a value that is not in the list.

Attributes that work on inputs

AttributeDoes
nameThe key the value is submitted under
valueThe starting value
placeholderA hint shown while the field is empty (not a label)
requiredMust be filled in before submitting
disabledCannot be used, and is not submitted
readonlyCannot be edited, but is submitted
autocompleteWhat to autofill: email, name, current-password, one-time-code, off
min, max, stepLimits for numbers, ranges, dates and times
minlength, maxlengthLength limits for text types
patternA regular expression the whole value must match
inputmodeWhich phone keyboard to show: numeric, decimal, email, tel, url
listThe id of a <datalist>
multipleSeveral values, for email and file
acceptFile types for file

Common mistakes

  • type="number" for phone numbers, zip codes or card numbers. They are not quantities. Use tel or text with inputmode="numeric".
  • A price field without step="0.01". Decimal values fail validation.
  • Using placeholder as the label. It disappears as soon as the reader types.
  • Relying on accept or type="email" for security. They are conveniences; the server checks again.
  • type="month" or type="week" without a fallback. Some browsers show a plain text field.
  • A closing </input> tag. <input> is void.

Frequently Asked Questions

How many input types are there in HTML?

22: button, checkbox, color, date, datetime-local, email, file, hidden, image, month, number, password, radio, range, reset, search, submit, tel, text, time, url and week. An unknown or missing type behaves as text.

What is the default input type in HTML?

text. An <input> with no type, or with a type the browser does not know, is a single-line text field.

Should I use type="number" for phone numbers or zip codes?

No. number is for quantities: it adds spin buttons, and it rejects the +, spaces and hyphens that phone numbers contain. Use type="tel" for phone numbers, and type="text" with inputmode="numeric" for codes like zip codes and card numbers.

What format does input type date use?

The value is always YYYY-MM-DD, such as 2026-09-24, whatever format the reader sees on screen. The display follows the reader's locale; the submitted and scripted value does not.

Does the input tag need a closing tag?

No. <input> is a void element: write <input type="text" name="city">. A closing </input> is invalid, and the self-closing slash in <input /> is allowed but does nothing.

Coddy programming languages illustration

Learn to code with Coddy

GET STARTED