THE WORLD'S LARGEST WEB DEVELOPER SITE

HTML <input type="text">

❮ HTML <input> type attribute

Example

Define a single-line text field that a user can enter text into:

<label for="fname">First name:</label>
<input type="text" id="fname" name="fname">
Try it Yourself »

Definition and Usage

The <input type="text"> defines a single-line text field.

The default width of the text field is 20 characters.

Tip: Always add the <label> tag for best accessibility practices!


Browser Support

Attribute
type="text" Yes Yes Yes Yes Yes

Syntax

<input type="text">

❮ HTML <input> type attribute