HTML Input Types


Lesson 29 of 58

HTML forms collect user input using different types of input fields. The type attribute tells the browser what kind of input to display, such as text, password, checkbox, or date picker.

By default, if you do not specify a type, the browser uses type="text".


Common Input Types Overview

Type Description
textSingle-line text input
passwordPassword field (characters are masked)
submitButton to submit form data
resetButton to reset form fields
radioSelect ONE option from a group
checkboxSelect ZERO or MORE options
buttonClickable button (usually with JavaScript)
colorColor picker
dateDate picker
emailEmail address (validates format)
fileFile upload field
numberNumeric input (with up/down arrows)
rangeSlider control
searchSearch field
telTelephone number
timeTime picker
urlURL address
hiddenHidden field (not visible to user)

Input Type Text

The type="text" creates a single-line text input field. Use it for names, addresses, or short answers.

Text Input Example

Input Type Password

The type="password" creates a password field. The characters are masked with dots or asterisks so others cannot see what is being typed.

Password Input Example

Input Type Submit

The type="submit" creates a button that sends the form data to the server. The action attribute specifies where to send the data.

Submit Button Example

Input Type Reset

The type="reset" creates a button that resets all form fields to their default values.

Reset Button Example

Input Type Radio (Select ONE)

The type="radio" creates radio buttons. All radio buttons with the same name belong to a group. Users can select only ONE option from the group.

Radio Buttons Example

Input Type Checkbox (Select ZERO or MORE)

The type="checkbox" creates checkboxes. Users can select zero, one, or multiple options from a list.

Checkboxes Example

Input Type Button

The type="button" creates a clickable button. It does nothing by default. You need JavaScript to make it do something.

Button Example

Input Type Color (Color Picker)

The type="color" creates a color picker. Click the field to choose a color.

Color Picker Example

Input Type Date

The type="date" creates a date picker. Click the field to choose a date from a calendar.

Date Picker Example

Date with min and max restrictions:

Date with Restrictions

Input Type Email

The type="email" is for email addresses. Browsers automatically validate the format. On mobile, the keyboard shows “@” and “.com” for easier typing.

Email Input Example

Input Type File

The type="file" creates a file upload field. Users can browse their computer and select a file to upload.

File Upload Example

Input Type Number

The type="number" creates a numeric input field with up/down arrows. You can set restrictions like min, max, and step.

Number Input Example

Input Type Range (Slider)

The type="range" creates a slider control. The exact value is not important, just the general range. You can set min, max, and step.

Range Slider Example

Input Type Search

The type="search" is designed for search fields. On some browsers, it adds a clear button to remove the text.

Search Field Example

Input Type Tel (Telephone)

The type="tel" is for telephone numbers. On mobile, it shows a numeric keypad. You can use the pattern attribute to enforce a specific format.

Telephone Input Example

Input Type Time

The type="time" creates a time picker. Users can select a time without a timezone.

Time Picker Example

Lesson 29 of 58