Description

The <input> tag is used to create interactive controls within a form.

An <input> element can vary in the way it appears and the attributes it uses or requires depending on the type attribute specified.

The following table summarizes the usages context and the version history of this tag.

Placement:Inline
Content:None. It is an empty element.
Start/ End Tag:Start tag: required, End tag: forbidden
Version:HTML 2, 3.2, 4, 4.01, 5

Syntax

The basic syntax of the <input> tag is given with:

HTML:<input>; XHTML:<input />

The example below shows the <input> tag in action.

<form action="action.php" method="post">
    <label for="first-name">First name:</label>
    <input type="text" name="first-name" id="first-name">
    <input type="submit" value="Submit">
    <input type="reset" name="Reset">
</form>

Tip: Use the HTML <label> element to define the labels for input controls. It will make the form more accessible for user.

Tag-Specific Attributes

The following table shows the attributes that are specific to the <input> tag.

Global Attributes

Like all other HTML tags, the <input> tag supports the global attributes in HTML5.

Event Attributes

The <input> tag also supports the event attributes in HTML5.

Browser Compatibility

Element
<input>YesYesYesYesYes