The most basic input type and the default input if no
type is specified. This input type defines a single-line text field with line-breaks automatically removed from the input value. All other characters can be entered into this.
<input> elements are used within a
<form> element to declare input controls that allow users to input data.
or (without specifying a
type, using the default attribute):
The default width of a text field input is 20 characters. This can be changed by specifying a value for the
size attribute like this:
<input type="text" size="50">
size attribute is distinctly different than setting a width with CSS. Using a width defines a specific value (in number of pixel, percentage of the parent element, etc.) that the input must always be wide. Using the
size calculates the amount of width to allocate based on the font being used and how wide the characters normally are.
Note: Using the
size attribute does not inherently limit the number of characters which can be entered into the box, only how wide the box is displayed. For limiting the length, see Input Validation.