text box


<input type="text">

Browser
Internet Explorer Firefox Opera
Type
Inline-block Empty

The INPUT element defines an input field. When you specify "text" for the type attribute of this element, a text box is created.


<input type="text" name="name1">

<input type="text" name="name2" size="30" maxlength="30" value="Example">


Attribute Value Explanation
type=" " text the type of input field (the default is "text")
name=" " field name a unique name for the field
size=" " number of characters the input field width
maxlength=" " number of characters the maximum number
value=" " initial value the text displayed in the field

type="text"

Creates a text box on the form.

name=""

The field name is used to identify the form field.

size=""

The input field width is specified by the number of characters.

maxlength=""

Specifies the maximum number of characters allowed in the input field.

value=""

Specifies the initial text displayed in the input field.

Tips and Notes

The style of the input field can be changed with CSS. Please see the "Related Document" for details on CSS.


Example

<form method="POST" action="example.cgi">

<p>Default<br>
<input type="text" name="example1"></p>

<p>size="40"<br>
<input type="text" name="example2" size="40"></p>

<p>maxlength="10"<br>
<input type="text" name="example3" size="40" maxlength="10"></p>

<p>value="Hello!"<br>
<input type="text" name="example4" size="40" value="Hello!"></p>

</form>
Output

Default

size="40"

maxlength="10"

value="Hello!"

This form cannot submit because of a sample.