defines a single-line text field. An HTML form with three input fields; two text fields and one submit button:The name attribute specifies the name of an element.The name attribute is used to reference elements in a JavaScript, or to
.
. While using this site, you agree to have read and accepted our If you'd like to contribute to the data, please check out . An HTML form with three input fields; two text fields and one submit button:
. The compatibility table on this page is generated from structured data. W3Schools is optimized for learning, testing, and training. Here are the different input types you can use in HTML: . size: Specifies the width of the input in characters. The value attribute is a DOMString that contains the current value of the text entered into the text field.

. If you haven’t already created an account, you will be prompted to do so after signing in. The type attribute specifies the type of element to display. HTML Input Types. If the type attribute is not specified, the default type is "text". . The default width of the text field is 20 characters. Sign in to enjoy the benefits of an MDN account. You can retrieve this using the value property in JavaScript.If no validation constraints are in place for the input (see Validation for more details), the value may be an empty string (\"\"). If you'd like to contribute to the interactive examples project, please clone If no validation constraints are in place for the input (see The maximum number of characters (as UTF-16 code units) the user can enter into the The minimum number of characters (as UTF-16 code units) the user can enter into the If the specified pattern is not specified or is invalid, no regular expression is applied and this attribute is ignored completely.A Boolean attribute which, if present, means this field cannot be edited by the user. . Definition and Usage. The source for this interactive example is stored in a GitHub repository.



. Its An input field can have spell checking enabled if it doesn't have the The following non-standard attributes are also available on some browsers. Examples might be simplified to improve reading and basic understanding. As a general rule, you should avoid using them unless it can't be helped.A Mozilla extension, supported by Firefox for Android, which provides a hint as to what sort of action will be taken if the user presses the When submitted, the data name/value pair sent to the server will be You can provide a useful placeholder inside your text input that can provide a hint as to what to enter by including using the The placeholder is typically rendered in a lighter color than the element's foreground color, and automatically vanishes when the user begins to enter text into the field (or whenever the field has a value set programmatically by setting its The physical size of the input box can be controlled using the There are useful pseudo-classes available for styling form elements to help the user see when their values are valid or invalid. . Tip: Always add the