Learn HTML Input Element

#iwritecode

What is Input Element or Tag

The <input> the tag specifies an input field where the user can enter data.
The <input> element is the most important form element.
The <input> the element can be displayed in several ways, depending on the type attribute.

Input type Attribute

The type attribute specifies the type of <input> element to display.
If the type attribute is not specified, the default type is "text"

Syntax

<input type="value">

Example

Attribute Values

TypeDescriptionSyntaxExamples
buttonA push button with no default behavior displays the value of the value attribute, empty by default.<input type="button" name="button" value="Button" />Example → Button
checkboxA check box allowing single values to be selected/deselected.<input type="checkbox" name="checkbox"/>Example →CheckBox
colorA control for specifying a color; opening a color picker when active in supporting browsers.<input type="color" name="color"/>Example → color
dateA control for entering a date (year, month, and day, with no time). Opens a date picker or numeric wheels for a year, month, and day when active in supporting browsers.<input type="date" name="date"/>Example → Date
NumberA control for entering a number. Displays a spinner and adds default validation. Displays a numeric keypad in some devices with dynamic keypads.<input type="number" name="number"/>Example → Number
fileA control that lets the user select a file. Use the accept attribute to define the types of files that the control can select.<input type="file" accept="image/*, text/*" name="file"/>Example → file
rangeA control for entering a number whose exact value is not important. Displays as a range widget defaulting to the middle value. Used in conjunction with min and max to define the range of acceptable values.<input type="range" name="range" min="0" max="25"/>Example → range
passwordA single-line text field whose value is obscured. Will alert the user if the site is not secure.<input type="password" name="password"/>Example → password

Resources

Javapoint W3school MDN