HTML Input Elements

·

2 min read

Definition and Usage

The tag specifies an input field where the user can enter data.

The element is the most important form element.

The element can be displayed in several ways, depending on the type attribute.

The HTML element is used to create interactive controls for web-based forms in order to accept data from the user; a wide variety of types of input data and control widgets are available, depending on the device and user agent. The element is one of the most powerful and complex in all of HTML due to the sheer number of combinations of input types and attributes.

Input types

How an input works varies considerably depending on the value of its type attribute, hence the different types are covered in their own separate reference pages. If this attribute is not specified, the default type adopted is text.

Some common available types are as follows:

- button

A push button with no default behavior displaying the value of the value attribute, empty by default.

- checkbox

A check box allowing single values to be selected/deselected.

- email A field for editing an email address. Looks like a text input, but has validation parameters and relevant keyboard in supporting browsers and devices with dynamic keyboards.

- number

A control for entering a number. Displays a spinner and adds default validation. Displays a numeric keypad in some devices with dynamic keypads.

- password

A single-line text field whose value is obscured. Will alert user if site is not secure.

- submit

A button that submits the form.